|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Merge *.csv files, each in separate sheets
Does anyone know how to Merge *.csv files, each in seperate sheets?
|
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
You can do this in Perl, search for examples using Spreadsheet::WriteExcel Perl module.
|
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Need more info
You can append them to one another.
You can paste them next to each other. You could write something to do all the line 1's, then line 2's,... What do you mean by merge? |
|
#4
|
|||
|
|||
|
There is a script which everyday generates a new csv file.
By merge I mean: each different sheets which were created for each day should be all together in 1 file but different sheets. thats why just copy-paste everyday doesnt answer. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
show some examples of CSV files and format, and tell us what you need get from them.
|
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Code:
#!/bin/bash
find /a/b -name "*.log" -mtime 0 -exec cat "{}" \; >> aa.log # finds all log files in a special path
grep -e XXX -e YYY aa.log | grep -v ZZZ | awk '{print $1 " " $2 ";" $3 ";" $9 ";" $11}' | cut -d ' ' -f3- <<<"$8" >> aa.csv # looks for XXX and YYY and ignores ZZZ, looks for fields: $1,.... and import then in aa.csv
sed -i '1iDate;Time;From;To' aa.csv # makes header as Date,Time,From,To echo "done."as you see my headers are date, time, from, to. everyday it genereates new data based on this header with a new date. I just want each date(each new generated sheet) be in one csv next to the yesterday generated sheet. preferably not to use perl.
Last edited by Scrutinizer; 12-11-2012 at 05:36 AM.. Reason: code tags |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
With sheet you mean a worksheet in MS-Excel? csv (Comma-Seperated-Values or Character-Separated-Values) is a file format that does not support a construct called sheet. Excel is an application you can use to view and edit .csv files, but you can use any editor/viewer/pager to do so.
If you need multiple csv-files on different Excel-worksheets you'll have to use an Excel-file (.xls or .xlsx) to store them. Why not perl? It has good libraries for this task and to my knowledge is the most used tool to handle Excel-files in scripts. Last edited by cero; 12-11-2012 at 06:29 AM.. Reason: Typos |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| create separate files from one excel file with multiple sheets | harris | Shell Programming and Scripting | 3 | 10-05-2012 02:38 AM |
| Merge 2 CSV files using sed | NewToSed | Shell Programming and Scripting | 9 | 04-24-2011 12:19 PM |
| Merge 2 csv files with awk | loloAix | Shell Programming and Scripting | 6 | 12-16-2010 04:32 AM |
| How to create a CSV File by reading fields from separate files | mayanksargoch | Shell Programming and Scripting | 2 | 07-07-2010 04:11 AM |
| Add multiple .csv files as sheets to an excel file in unix. | libin4u2000 | Shell Programming and Scripting | 2 | 01-20-2009 10:20 PM |
|
|