Find the answer to your Linux question:
Results 1 to 4 of 4
I am fairly new to Linux and need to bring some file information into a spreadsheet. I am trying to go through a directory and it's subdirectories, grab information from ...
  1. #1
    Just Joined!
    Join Date
    May 2007
    Posts
    2

    write file information to spreadsheet

    I am fairly new to Linux and need to bring some file information into a spreadsheet. I am trying to go through a directory and it's subdirectories, grab information from all htm and html files, and write it to an open office spreadsheet. I would like to write the path (subdirectory), file name, title and description to their own columns.

    I was able to get the path and file names of all files to a text file, but I have been unable to either filter for htm and html files or write to columns in a spreadsheet.

    Any advice would be appreciated.

  2. #2
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Location
    Maryland, USA
    Posts
    506
    Which spreadsheet are you using?

    As a test I just did this
    ls -tora > list.txt
    Then I opened the gnumeric spreadsheet and: File -> open -> list.txt

    It separated the file into columns pretty natually, though there is also this, which I haven't tried:
    Data -> Text to Columns...

  3. #3
    Just Joined!
    Join Date
    May 2007
    Posts
    2
    Thank you for your reply.

    I am using the Open Office Calc spreadsheet.

    I modified the ls -tora > list.txt command by changing .txt to .ods (the extension used by Open Office). The file produced opened with the Open Office Word Processor, even when I tried to open it from the spreadsheet application. I also added R to tora to get the contents of the subdirectories.

    I need to filter for htm and html files. I would also like to grab some text from the contents orf the files, between <TITLE> and </TITLE>.

  4. #4
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Location
    Maryland, USA
    Posts
    506
    It sounds like you have two separate problems: parsing the data and importing the data.

    For parsing the data, you may want to try something like this:
    Code:
    for f in $(find . -name *.html); do
        echo -n "$f  "; sed -n 's#.*<\(title\|TITLE\)>\(.*\)</.*#\2#p' $f >> data.txt
    done
    As for importing text into OpenOffice Calc, copy the text into the clipboard and paste it into the spreadsheet. That causes a "Text Import" wizard to popup allowing you to select various things, like delimiters.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...