|
|
|
date: Wed, 20 Aug 2008 23:41:07 +0300,
group: microsoft.public.inetsdk.programming.scripting.vbscript
back
Re: split txt file
Il giorno Wed, 20 Aug 2008 23:41:07 +0300, Mike Berger ha scritto:
>I have a txt file (C:\test\kunden.txt) like follow:
>Gruppe_1;Name;Vorname
>Gruppe_1;Name1;Vorname1
>Gruppe_2;Name1;Vorname1
>Gruppe_2;Name2;Vorname2
>Gruppe_2;Name3;Vorname3
>...
>about 150 groups, with 500 names
>
>Now I will split the kunden.txt file into
>
>gruppe_1.txt
> Gruppe_1;Name;Vorname
> Gruppe_1;Name1;Vorname1
>
>gruppe_2.txt
> Gruppe_2;Name1;Vorname1
> Gruppe_2;Name2;Vorname2
> Gruppe_2;Name3;Vorname3
>
>How can I do that?
You can open ForReading the kunden.txt file,
find the ";" with instr and get the name of the new file with
left(line,instr(line,";")-1)&".txt"
with fso.fileexist check if the file already exists, otherwise create it with the
FileSystemObject.
You can alse send every line to its file using the ForAppending parameter.
If you are sure the grouppe are not mixed, you can compare every line to the previous and
write the current line to the correct file (create it if necessary).
The use of FileSystemObject and instr are described in wsh.chm and script56.chm
--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
date: Fri, 22 Aug 2008 21:30:49 GMT
author: (Reventlov)
|
|