[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



Also, it should be noted that this will concatenate the output of EVERY 
.csv file in that directory.  If you have .csv files you don't want 
appended to "append.csv" you need to make adjustments accordingly.

Kind regards,
CB


Christopher Bergeron wrote:

> Jay, try this:
>
> rm append.csv
> echo > append.csv
> for i in `cat *.csv`; do cat $i >> append.csv; echo -e "\n" >> 
> append.csv; done
>
> Basically what this will do is:
> a) remove any existing append.csv file that you have (I'm assuming 
> that's what you want)
> b) create an empty file called append.csv (optional step; just added 
> for robustness)
> c) for each .csv file, cat it into append.cvs and then echo a newline 
> after it
>
> I've just started learning AWK and I have a feeling that it might be 
> better suited for this, but you asked how to do it in bash.
>
> I'd be interested to know how others would do this though - 
> particularly because sed has some nasty quirks when it comes to newlines.
>
> Best regards,
> CB
>
>
>
>
> jay wrote:
>
>> Here's the scoop...I have about 330 csv files that are results files 
>> from a survey.  I want to import them into a spreadsheet for 
>> graphing, but when coding the survey in php, my partner and I didnt 
>> place a line break after each results file finishes. 
>> The result is 330 files like this:
>> 2,0,0,1,1,3,1,10,2,0,2,1,1,0,    *    "short answer"
>> Each file is one line, with a set of comma deliminated numerical 
>> answers, then one short answer question, separated by the star as you 
>> see above.  What I want to do is basically:
>> cat *.csv > append.csv
>> but I want to add a linebreak between each file.  I can code this in 
>> python, but that seems unnecessarily complicated, and I'm almost 
>> positive if I knew how to utilize the shell better, I could do this 
>> in one command....can anyone shed some light on this for me?
>> Thanks!
>>
>> -Jay
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
&gt;&gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>
&gt;&gt;
&gt;&gt;  
&gt;&gt;
&gt;
&gt;


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00696" href="msg00696.html">[ale] help with a tiny shell script - correction</a></strong>
<ul><li><em>From:</em> jloden at toughguy.net (Jay Loden)</li></ul></li>
<li><strong><a name="00697" href="msg00697.html">[ale] help with a tiny shell script - correction</a></strong>
<ul><li><em>From:</em> jonathan.glass at ibb.gatech.edu (Jonathan Glass)</li></ul></li>
<li><strong><a name="00705" href="msg00705.html">[ale] help with a tiny shell script - correction</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00692" href="msg00692.html">[ale] help with a tiny shell script</a></strong>
<ul><li><em>From:</em> jloden at toughguy.net (jay)</li></ul></li>
<li><strong><a name="00693" href="msg00693.html">[ale] help with a tiny shell script</a></strong>
<ul><li><em>From:</em> christopher at bergeron.com (Christopher Bergeron)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00693.html">[ale] help with a tiny shell script</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00695.html">[ale] help with a tiny shell script</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00693.html">[ale] help with a tiny shell script</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00696.html">[ale] help with a tiny shell script - correction</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00694"><strong>Date</strong></a></li>
<li><a href="threads.html#00694"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>