Re: SED: Insert Token at specific points

From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 06/30/05


Date: Thu, 30 Jun 2005 11:04:15 GMT

On comp.unix.shell, in <PYPwe.13940$pa3.7929@newsread2.news.atl.earthlink.net>, "Alan Connor" wrote:
>
>
> On comp.unix.shell, in <42C3BDDB.90304@gmx.de>, "Thorsten Knopel" wrote:
>>
>>
>> Hello
>>
>> I hada little problem
>>
>> we Data (CSV) files with following schema
>>
>> DATA "Karl" "2" "OLGA" "4" "5" "6" "TOTO" ... "70"
>> DATA "1" "MEL" "URGA" "4" "SEPP" "6" "TOT" ... "70"
>>
>>
>> And we want insert empty values at position 3 and 5
>>
>> DATA "Karl" "2" "OLGA" "" "4" "5" "" "6" "TOTO" ... "70"
>> DATA "1" "MEL" "URGA" "" "4" "SEPP" "" "6" "TOT"... "70"
>
> sed -n 's/^\(DATA \)\(\"[^"]*\"\)\( \"[^"]*\" \)\(\"[^"]*\"\)\
> \( \"[^"]*\" \)\(\"[^"]*\"\)\ \(.*\)/\1\2 \3 \"\" \5 \"\" \
> \7/p' inputfile > outputfile
>

It just occurred to me that is probably a really long file. So
test it this way:

sed -ne 'what's inside the single quotes above' -e '200q' \
 inputfile | less

AC



Relevant Pages

  • Re: SED: Insert Token at specific points
    ... > we Data (CSV) files with following schema ... mv outputfile inputfile # AFTER testing carefully! ...
    (comp.unix.shell)
  • Re: What is the logic of storing XML in a Database?
    ... Does that mean that CSV data with a header can't be validated? ... proprietary schema format for flatfiles and sell a proprietary tool ... for validating a CSV file that conforms to the flat file. ...
    (comp.databases.theory)
  • Re: BizTalk 2006 RT2 > BizTalk Mapping
    ... schema in a BizTalk application? ... I have 15 .csv files which I suppose to import in commerce server. ... -Create maps for each of the .csv schemas (1_to_Int.btm, ...
    (microsoft.public.biztalk.general)
  • SED: Insert Token at specific points
    ... we Data (CSV) files with following schema ... And we want insert empty values at position 3 and 5 ... the pattern will be to big. ...
    (comp.unix.shell)
  • Re: Creating a Child Record with a different Namespace
    ... I took your schema, and changed the Person node to be ... three separate output documents as expected. ... instead of the one the <CSV> node is in. ... just change at the schema level the element form default ...
    (microsoft.public.biztalk.general)