Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Regex Parsing Fixed Width

pacopenamedina
7 - Meteor

I am trying to parse with Regex a file that needs to be split into many columns. When I input the file and used fixed width it tells you how many spaces it needs so using that I tried to apply those spaces with REGEX so that when I update the file with the new file in a new directory, I don't have to reset the Fixed width settings or do anything like that.

 

Here is an example of my Data but very generalized:

12345BUD  2  0.00 203132 123123

20221242   500003  23423  123

20221231   230012  23123  123

12345LET  3  0.00  20312     23123

20221242   500003  23423  123

20221231   230012  23123  123

20221231   230012  23123  123

When I set it up with Regex the lines with letters returns all nulls.

It also says that not all my records were successfully parsed.

 

This is what I have in my regular expression settings.

(.{9})(.{3})(.{9})(.{9})(.{12})(.{6})(.{13})(.{4})(.{15})(.{9})(.{12})(.{7})(.{8})(.{4})(.{12})(.{12})(.{12})(.{17})(.{8})(.{7})(.{6})(.{7})(.{7}+)

This works for all lines except the lines with letters.

How can I fix this?

5 REPLIES 5
binuacs
21 - Polaris

@pacopenamedina what are the field length for the given input?

pacopenamedina
7 - Meteor

I just set it as 2000 I assumed that would be big enough, is that a wrong thing to do?

binuacs
21 - Polaris

@pacopenamedina I mean in the above sample input file what are the length of each field to be parsed? Is the length of the first field should be 9, the second should be 3 then 9, 9 etc?

pacopenamedina
7 - Meteor

Yes that is correct, but the example I gave is simplified

binuacs
21 - Polaris

@pacopenamedina try the below method

image.png

Labels
Top Solution Authors