Search code examples
regexcsvformattingstring-formattinglibreoffice

Formatting text file


I have a txt file that I would like to alter so I will be able to place the data into columns see example below. The reason behind this is so I can import this data into a database / array and perform calculations on them. I tried importing/pasting the data into LibreCalc but it just imports everything into one column or it opens the file in LibreWriter I'm using ubuntu 10.04. Any ideas? I'm willing to use another program to work around this issue. I could also work with a comma delimited file but I'm not to sure how to convert the data to that format automatically.

Trying to get this:
WAVELENGTH,   WAVENUMBER,   INTENSITY,    CLASSIFICATION,     CODE,
1132.8322,    88274.326,     2300,        PT II,   9356- 97630,       05,

Here's a link to the full file. pt.txt file


Solution

  • The easiest way turned out to be importing using a fixed width like tohuwawohu suggested Thanks

    Without transforming it to a comma-separated file, you could access the csv import options by simply changing the file extension to .csv (maybe you should remove the "header" part manually, so that only the columns heads and the data rows do remain). After that, you can try to use whitespace as column delimiter, or even easier: select "fixed width" and set the columns manually. – tohuwawohu Oct 20 at 9:23