[SOLVED] Mutipule .xls files convert into single .csv
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.
why are you skipping line 1 and then skipping 6 lines ?
do you want to ignore the first 7 rows?
edit you are starting at row 1, then dropping 6
why not start at 7?
the code was skipping first 6 rows for each file and converted to single .csv file. It is working fine as expected. Now, I want to capture files names into single .log file for audit purpose.
the code was skipping first 6 rows for each file and converted to single .csv file. It is working fine as expected. Now, I want to capture files names into single .log file for audit purpose.
Do you have any idea ?
you do not need the tail
change
FilterOptions="59,0,0,1"
to
FilterOptions="59,0,0,6"
what file names?
the original xls files or the new csv ?
where is the log?
audit?
I doubt you guys have any real audit system in place after what I have seen.
You would have been retrained,
if that didn't work reassigned
if that didn't work dismissed.
Code:
#!/bin/bash
Output="/path/to/onebigfile.csv"
LogFile="/path/to/somelog.log"
for xls in /path/to/incomingDir/*.xls
do
unoconv -f csv \
-e FilterOptions="59,34,76,7" \
"${xls}" \
--stdout \
>> "${Output}"
printf "$(date +%F\ %T.%N\ %Z) \"${xls}\" appended to \"${Output}\"\n" >> "${LogFile}"
done
Last edited by Firerat; 09-22-2019 at 11:24 AM.
Reason: 6 or 7 ? I have no idea, changed to 7 anyway
the code was skipping first 6 rows for each file and converted to single .csv file. It is working fine as expected. Now, I want to capture files names into single .log file for audit purpose.
Do you have any idea ?
Well, you must know the file names in order to convert them. To write something to a log file, use echo.
This will capture all the files which are present in the current directory. But i want list of files are converted druing below code process ?
ls test_amount*.xls >> logfile.log -- This will not work for me.
for input in /test/test_amount_*.xls; do
unoconv -f csv -e FilterOptions="59,0,0,1" --stdout $input | tail -n +6
done > /test/bigfile.csv
The above code were processed 10 .xls files to single .csv file. I want to capture all 10 file names into >> filnames.log file. This time it was converted 10 files next run it may convert into 100 files etc...
Hope you understand my point?
I tried below option but didn't work for me.
for input in /test/test_amount_*.xls; do
unoconv -f csv -e FilterOptions="59,0,0,1" --stdout $input | tail -n +6
done > /test/bigfile.csv | $input >> filename.log
Convert from and to any format supported by LibreOffice
unoconv options:
-c, --connection=string use a custom connection string
-d, --doctype=type specify document type
(document, graphics, presentation, spreadsheet)
-e, --export=name=value set export filter options
eg. -e PageRange=1-2
-f, --format=format specify the output format
-i, --import=string set import filter option string
eg. -i utf8
-l, --listener start a permanent listener to use by unoconv clients
-n, --no-launch fail if no listener is found (default: launch one)
-o, --output=name output basename, filename or directory
--pipe=name alternative method of connection using a pipe
-p, --port=port specify the port (default: 2002)
to be used by client or listener
--password=string provide a password to decrypt the document
-s, --server=server specify the server address (default: 127.0.0.1)
to be used by client or listener
--show list the available output formats
--stdout write output to stdout
-t, --template=file import the styles from template (.ott)
-T, --timeout=secs timeout after secs if connection to listener fails
-v, --verbose be more and more verbose (-vvv for debugging)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.