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?
@pacopenamedina what are the field length for the given input?
I just set it as 2000 I assumed that would be big enough, is that a wrong thing to do?
@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?
Yes that is correct, but the example I gave is simplified
@pacopenamedina try the below method
User | Count |
---|---|
107 | |
82 | |
70 | |
54 | |
40 |