Quick way to convert spaces in text file to tabs to copy to spreadsheet?
Hi.
I have a file with dates and then weights (kg). They are separated by a space. i.e.: 2019-08-01 68.7 I'd like to copy this long list to a spreadsheet once in a while to show a graph of my weight and other peoples weights. Is there a quick method to do this? Thanks. |
tr, sed, awk, perl, python, ...
Start with the manpage for tr. |
Quote:
But from your side: Which language/tool do you prefer? What did you try so far? Where did you stuck? |
Code:
tr " " "\t" <original_file >converted_file Code:
sed "s/ /\t/" original_file >converted_file |
Depends on spreadsheet app. Excel and libreoffice as far as I know have the capability to select the delimiter i.e as a space, tab or comma etc or fixed width so conversion is probably not necessary.
|
So if the OP had made some effort .... :shrug:
|
Quote:
Quote:
Not so proficient with the Linux varieties of spreadsheets, but I know that one can import data and many times there's a preview of that data which shows, and allows you to change you delimiter so that you can get it right, while viewing the previews. So just try this, and I would prefer to stay away from a bunch of text processing tools. I do not feel they are necessary. Or, to be kinder about it. Have you already tried this, and found it to be flawed in some manner? |
Calc will import the file fine checking 'space' as a delimiter.
Off Topic: I understand the rationale for asking someone who just joined what they have tried but IMO grilling a Contributing Member who has 3500+ posts is unnecessary. Just my 2 cents. |
Quote:
|
Quote:
|
1 Attachment(s)
Quote:
|
I would use unexpand(1). It should already be on your distro :)
|
hm. I have never heard about expand/unexpand, both can be implemented easily in awk/perl/python/whatever, still interesting that we have a ready-made tool for this.
something to learn again. |
Quote:
|
Quote:
|
All times are GMT -5. The time now is 09:23 PM. |