Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Wed, 20 Aug 2008 23:41:07 +0300,    group: microsoft.public.inetsdk.programming.scripting.vbscript        back       


split txt file   
Hello,

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?

Mike
date: Wed, 20 Aug 2008 23:41:07 +0300   author:   Mike Berger

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)

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us