Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Regex Parsing

anom23
7 - Meteor

Hello

 

I am new to the Alteryx community and wondered if anyone has an idea on how to parse the attached file?  Below is the file layout.  So far in my workflow i have been able to upload the file but I am having difficulty parsing the file and producing the required field names.  Any help would be great.

 


OFFSET       FIELD NAME           LENGTH       DATA DEFINITION
001 – 015      Account                    15                PIC 9(15)
16                  Filler                         1                  PIC X. Value Null.
017 – 026     Location                     10                PIC 9(10) (ULID)
27                 Filler                           1                   PIC X Value Null.
028 – 031    Return Date (MMDD)  4                PIC 9(4)
32               Filler                             1                PIC X Value Null.
033 – 036    Date (MMDD)             4                PIC 9(4)
37               Filler                           1                 PIC X Value Null.
038 – 046  Transit Number            9                PIC 9(9)
47               Filler                           1                PIC X Value Null.
048 – 062   Account Number          15              PIC 9(15)
63               Filler                           1                PIC X Value Null.
064 – 073 Serial Number            10               PIC 9(10)
74              Filler                          1               PIC X Value Null.
075 – 084  Amount ($$$$$$$$cc) 10           PIC 9(8)V99
85              Filler                           1              PIC X Value Null.
086 – 087  Return Reason           2               PIC XX
88              Filler                           1                PIC X Value Null.
089 – 128 Maker Name              40              PIC X(40) (Left Justify, Blank Fill)
129          Filler                           1                PIC Value Null.
130          Disposition Indicator  1                   PIC X



9 REPLIES 9
Elias_Nordlinder
11 - Bolide

Hello @anom23,

 

Could you give a little bit more info in how the input that you want to parse look like and your desired output.

 

In the text file attached the layout looks very different than the file layout you posted in the comment above.
If you could give an example workflow, or an input file on what to parse I can try to help you.

 

//Best Regards
Elias 

apathetichell
18 - Pollux

I love regex parsing and you can do what you are asking with a regex tool set to parse mode with (.{15))/s(.{10})/s - etc... or you can bring it as plain undelimited text and then cut it apart using /s as the delimiter and 10 columns.

atcodedog05
22 - Nova
22 - Nova

Hi @anom23 

 

Your input file doesnt seem to match your expected output 🤔 is the right file?

anom23
7 - Meteor

Hi Elias

 

Sure....when I use the dynamic text input filed my column looks like below. I am not sure if that helps or not, but the file was provided by another source.

 

anom23_0-1628682343594.png

 

atcodedog05
22 - Nova
22 - Nova

Hi @anom23 

 

Can you provide the actual file loaded and expected output.

anom23
7 - Meteor

Sure hope this helps.

messi007
15 - Aurora
15 - Aurora

@anom23,

 

Please see below

 

messi007_0-1628686803380.png

 

Attached the workflow.

 

Hope this helps!

 

Regards

anom23
7 - Meteor

So I was able to use this regex expression for the below file structure - (\d{15})(\d{10})(\d{4})(\d{4})(\d{8})(\d{15})(\d{10})(\d{10})(\d{2})\s+([C|R])

 

Old FIle - 000000300004200 0000000000 0821 0814 01110309 000004333292376 0000995504 0000000800 08 C

 

Which worked until I was provided with a new file structure that contains letters

 

New File - 000000324444587 0000000000 0821 0814 01110309 000004333292376 0000995504 0000000800 08 MAKER INFO FOR 323800007 C 

 

I attempted to use this expression but it does not parse - (\d{15})(\d{10})(\d{4})(\d{4})(\d{9})(\d{15})(\d{10})(\d{10})(\d{2})(\d{40})\s+([C|R])

 

Can anyone provide some insight at what I might be doing incorrectly?

apathetichell
18 - Pollux

Try swapping the second to last \d{10} with \w{10} (if that doesn't work swap a bunch/all of the \d's with \w's)

 

If this is going to happen with other sections you need clarity on what the potential values are going to be fed into the parse. There's a lot of hardcoded regex in your parse tool and it's only for digits right now. Also - it should end with a $ to clarify that you want the C/R as the last character.

Labels