bash - Multi line tab separated file to comma separated -


I have a large file that is different tabs The biggest problem is that I have to import the data into the database but some columns There are multi lines that are causing some problems, what I would like to do to convert the file, which converts the file into a different file than the right comma. Here is an example of a file (I will change the option of tab with pipe.):

  1 | Some text | Second lesson. 12 | Bigger bigger text with lots of data and many lines and commas. 34 34 2 | Some text | Another text || There are basically two rows of data in the above example, what I would like to do:  
 < Code> "1", "some text", "other text", "12", "bigger bigger text with lots of data and many lines" 34 "," 34 "," 34 "" 2 "," some Text "," Other text "," ", and another big big text with many letters in the tab", "33", "25"   

I can see Every full line of data (one With fie line column) is terminated by ^ M $, it looks like:

  1 | Some text | Another lesson. 12 | Bigger bigger text with lots of data and multiple lines and commas. 34 34 ^ M $ 2 | Some text | Second text || A big big big text with many letters, and tabs. 33 | 25 ^ M $    

This is really difficult, and it executes the correct sequence of substitutions Depends on doing Looks like the following is done (at least on your given example):

  "Attach non-multi-line lines with citations. G / \ t / s / ^ \ | \ (\ R \) $ / "\ 1 / g" Undo the quotation that ends / ends before the start of a multiline. V / \ t / -1s / "$ //: v / \ t / + 1s / ^ "//" undo an incomplete (i.e. no ^ m) starting bid after the previous record. : G / \ t / -1s / \ r \ @ & lt ;! \ N \ zs "//" Change the tab with quotation and commas:% S / \ t / "," / g "Finally, remove the ^ M-off-record marker.% S / \ r $ //    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -