Subject:
|
Re: Standardized Inventory File Format?
|
Newsgroups:
|
lugnet.db.inv
|
Date:
|
Thu, 23 Sep 1999 16:11:53 GMT
|
Viewed:
|
479 times
|
| |
| |
In lugnet.db.inv, Gary Williams writes:
> Steve Bliss wrote in message <37ea300b.59491442@lugnet.com>...
> > I suppose non-programmers could load the data file into a text editor
> > first, and search'n'replace all the tri-spaces with a comma.
>
> People may end up with multiple commas if there happens to be a gap of six
> or more spaces, then.
>
> Of course after replacing ' ' with ',', they could replace ',,' with ','.
> It might be necessary to run the second replace operation multiple times, if
> the program being used doesn't replace nested search strings (e.g., ',,,,'
> becomes ',,' after the first pass).
>
> Surely there's a better way.
Yes -- the way to do that type of transformation in a single operation is to
replace the grep expression / +/ with /,/. Of course, if you don't have grep
replace in your text editor, get a real text editor (-:
Just kidding! Every major OS can run Perl, and this 7-linePerl script will do
the processing for you:
open (IN, "myinv.inv");
open (OUT, "> myinv.cdt"); # cdt = comma delimited text
while ($l = <IN>) {
$l =~ s/ +/,/g;
print OUT $l;
}
close IN; close OUT;
- Robert Munafo http://www.mrob.com/
LEGO: TC+++(8480) SW++ #+ S-- LS++ Hsp M+ A@ LM++ YB64m IC13
|
|
Message has 2 Replies: | | Re: Standardized Inventory File Format?
|
| (...) So will: sed "s/ +/,/g" <spaces.txt >comma.txt Which will run on any machine (even an 8088 laptop) that has a DOS- or *nix-style command line. And sed is small enough that most people who might balk at Perl wouldn't mind installing it, even as (...) (24 years ago, 22-May-00, to lugnet.db.inv)
|
Message is in Reply To:
| | Re: Standardized Inventory File Format?
|
| Steve Bliss wrote in message <37ea300b.59491442@l...et.com>... (...) People may end up with multiple commas if there happens to be a gap of six or more spaces, then. Of course after replacing ' ' with ',', they could replace ',,' with ','. It might (...) (25 years ago, 23-Sep-99, to lugnet.db.inv)
|
25 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|