I can't import a file in a spreadsheet (Excel file)?!
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to "Import" this file to a spreadsheet "openoffice spreadsheet" in linux or "Microsoft Excel" in windows so that:
Informations like this line:
# type version valid task_time preempt_time code_bits task_power
to be shown in columns, I mean each item (like type, version, ...) in one column and the values below them in the related column.
But I want that the first column to be intended for the "comment" lines like:
# Angle to Time Conversion
# Basic floating point
# Bit Manipulation
...
So that the related value of each one, to be shown in front of each comment: in 2th column, 3th column, ...
I can do this work with copy them and paste in a spreadsheet file one by one, but I want it to be done completely Automatic!
One solution is: saving this file (.tgff) in ".csv" format in linux and select the "space" character as a separator.
but again, after opening it in the openoffice spreadsheet, we have to change some parts manually!
Anyway, is there a complete solution to do this?
Or is it required to have a program (some codes) to parse for example "#" items as "comment" in first column in linux and ...?
Or is there a Tool to do this in windows or specially in linux?
Or any Tip&Trick to do so?!
BTW, I've uploaded a sample ".xls" file in the following links to show the desired output in a spreadsheet together with ".tgff" file:
Looks like a suitable task for either awk or perl to me.
If the format of the text file is always the same - some
header info, #----, column headings ... - you can use awk
with NF and and then pattern matching to easily mangle text.
In Open Office, or even in excel, you can only do it table by table. I have observed that your data is not a one big table but a series of smaller ones.
If you're good at macros maybe you can code this. The Things that you have to do for a single table are this. This is in openoffice.
1. Copy a single table into spreadsheet, a text import dialog box will appear. Just ok it. This will make the data just dump in one column (assume at C1).
2. Assuming the column headers are in C5, put this formula in A7 : =IF(LEFT(C6,1)="#",C6,"") and in B6: =IF(LEFT(C6,1)="#","",C6) drag both formulas using handle button till the end Now, select all the formulaed cells, Ctrl+C, Ctrl+Shift+V and select only text option. I hope you got the comments beside the data.
3. Delete the copied data in C column, select from B6 to end, type Alt+d,x. You will get Text import dialog, Select Fixed Width, and put the separators in the gap between the items. Now you get the data in proper columns.
4. If you want to delete the unnecessary columns now, Select the table and put filter, from the dropdown list, select -empty- and select all the empty rows (shift +space) and ctrl + - them. Again select All from the dropdown list and remove the filter.
Post ur reply.
It might be possible to convert it to a CSV (comma-separated values, it's one of the simplest formats readable by a spreadsheet) file using perl or awk.
Basically, you are asking us to write, and give you a script to convert this file for you.
As you have probably realised, this isn't a trivial task, and we are unpaid (and frequently also unthanked) volunteers.
I suggest you read up on perl and awk, as suggested above, make a good attempt to write your own script, and then post it here if it isn't working for you, with the details of why it is failing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.