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

[no subject]



thanks for the help, it worked great. 

-Jay


On Tuesday 16 November 2004 12:58 am, Christopher Bergeron wrote:
> Correction:  the for line should read:
> for i in `\ls *.csv`; do cat $i >> append.csv; echo -e "\n" >>
> append.csv; done
> (for i in backtick backslash ls start dot csv backtick semicolon ...)
>
> 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;&gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>
&gt;
&gt; _______________________________________________
&gt; Ale mailing list
&gt; Ale at ale.org
&gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--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>
<li><strong><a name="00694" href="msg00694.html">[ale] help with a tiny shell script - correction</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="msg00695.html">[ale] help with a tiny shell script</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00697.html">[ale] help with a tiny shell script - correction</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00694.html">[ale] help with a tiny shell script - correction</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00697.html">[ale] help with a tiny shell script - correction</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00696"><strong>Date</strong></a></li>
<li><a href="threads.html#00696"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

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