0
wildblue

batch file/file formatting help

Recommended Posts

We've got enough geeks on here, I thought I'd ask -

I have a text file with a series of dates:

date1
date2
date3
date4

and I want to turn it into

date1,date2,date3,date4 (need to insert the ',' as well)

I was thinking a "for /F" statement might do what I want. It might even get rid of the leading and trailing spaces on each line (using sed to do that now)

Ideas?
it's like incest - you're substituting convenience for quality

Share this post


Link to post
Share on other sites
Or, make it profoundly simple. Copy and paste your list into Microsoft Word. Then, use the Find->Replace feature to seek out every carriage return (or paragraph character) and replace it with ", ".

I just tried this in Word and it worked just fine.

Misbehave!

~ topher
"...there is a there out there..." - Tom Robbins

Share this post


Link to post
Share on other sites
Quote

Or, make it profoundly simple. Copy and paste your list into Microsoft Word. Then, use the Find->Replace feature to seek out every carriage return (or paragraph character) and replace it with ", ".



If you can automate that with a batch file, I'd be hella impressed.

unformed - it's already part of a larger batch file, I could do it with perl or something pretty easily too, I'm just trying to use what's already there.
it's like incest - you're substituting convenience for quality

Share this post


Link to post
Share on other sites
http://www.roumazeilles.net/ygrep/ygrep.php

If you can't convince your significant other to wake up at 4AM to do this for you, then mash on the link above and do some digging. This is a program that can be installed and run from the command line. It allows you to perform search/replace functions from the command line (and therefore from batch files). This will require you to tinker with regular expressions a little bit, but the functionality you're working towards is not on the rocket-science end of the regular expression spectrum (which is good because regexs get confusing quickly).

Good luck,

topher
"...there is a there out there..." - Tom Robbins

Share this post


Link to post
Share on other sites
Quote

They pay you enough that you should be willing to wake up and do it by hand. :D:P

What language is the original batch in?



The fuck they do.

English.

B|

Anyway, the db guy finally figured out how to get the dates out as date,date,date - so I don't have to do it anymore. I just have to
s/^[ ]*//;s/[ ]*$//
and life should be good :D
it's like incest - you're substituting convenience for quality

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

0