Can I convert a table in a text file to Excel using RM?
kimjk3559
Altair Community Member
For example,
There is a text file with many tables of this type, and these to..
name age job des1 des2 des3
aaaa bbbb ccc 1 2 3
dddd eeee fff 4 5 6
I want to convert it to an Excel file of this type.
I tried filter with regular expression but I can't get the idea out.
Any help or even a little hint is appreciated.
Tks
name age job
--------------- ---------------- ---------------
aaaa bbbb ccc
aaaa bbbb ccc
des1 des2 des3
--------------- ---------------- ---------------
1 2 3
dddd eeee fff
dddd eeee fff
des1 des2 des3
--------------- ---------------- ---------------
4 5 6
There is a text file with many tables of this type, and these to..
name age job des1 des2 des3
aaaa bbbb ccc 1 2 3
dddd eeee fff 4 5 6
I want to convert it to an Excel file of this type.
I tried filter with regular expression but I can't get the idea out.
Any help or even a little hint is appreciated.
Tks
Tagged:
0
Best Answer
-
Hi!
Your tables are formatted for viewing, not processing. But you can still import them.
I would try Read CSV with a weird separator character that is not in the tables, like § or *. This gives you the entire rows in one column.
Then apply Trim to remove spaces in the beginning and the end of the rows. Then Split with a regular expression like "[\t ]+", this will split up the column on the variable number of spaces (or tabulators if they are in the data) . If the Name or some other attribute have (single) spaces in the contents, try a regular expression with a quantifier: {2,}|\t
Then you can rename the columns as you need.
When you're done, you can use Write Excel to export the results.
Regards,
Balázs0
Answers
-
Hi!
Your tables are formatted for viewing, not processing. But you can still import them.
I would try Read CSV with a weird separator character that is not in the tables, like § or *. This gives you the entire rows in one column.
Then apply Trim to remove spaces in the beginning and the end of the rows. Then Split with a regular expression like "[\t ]+", this will split up the column on the variable number of spaces (or tabulators if they are in the data) . If the Name or some other attribute have (single) spaces in the contents, try a regular expression with a quantifier: {2,}|\t
Then you can rename the columns as you need.
When you're done, you can use Write Excel to export the results.
Regards,
Balázs0 -
tks! I've used over 30 operators, but it worked anyway.0