Replace "|n" and spaces to comma and to "|n" in csv file using Textwrangler

38 views Asked by At

I have a problem to solve a huge file that have return for each value as well as spaces and it seems to have double return for new data set (new row). When replace "|n" with comma I get all data in one single row and that is not very workable. I'm not an expert in more advance handling of replace and need some help to solve this. The file looks as below and I need it to be like this: 71833,105310,PN004507,355622081384366,taxi981m,198101,98101A,5935332,935332,67.8454874,20.261657,20180701,070020,105310,181578 (new row) 71833,71976,PN004507 etc...

Is this manageable? I have not been able to solve this....

71833
105310
PN004507
355622081384366
taxi981m
198101
98101A
5935332
935332                                   67.8454874  20.261657 20180701 070020
          105310       181578

71833
71976
PN004507
355622081384366
taxi981m
198101
98101A
5935332
935332                                   67.8541771 20.2274661 20180701 070721
           71976       180337

71833
8537
PN004507
355622081384366
taxi981m
198101
98101A
5935332
935332                                   67.8508472 20.2242022 20180701 071136
            8537           -1

71833
4226
PN004507
355622081384366
taxi981m
198101
98101A
5935332
935332                                   67.8508472 20.2242022 20180701 071142
            4226           -1
1

There are 1 answers

0
QGIS-user On

I did manage finally :) ... using 5 steps with "Multi-file Search..."

This is the steps I used

  1. [ \t] + replace with , (to get rid of all spaces and replace with comma)
  2. [ \t] replace with , (one space replace with comma)
  3. \n\n replace with ;;; (double returns replace with 3 semicolons)
  4. \n replace with , (one return replace with comma)
  5. ;;; replace with \n (3 semicolons replace with one return)

I wonder if this could be done in one step, let me know if that is possible...