Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.

Splitting a text file?

I have a large text file containing structured data. What I need to do, is splitting it up to save it as a new document every fifth line.

for example

I hav a master file "Main.txt" containing he following

aaaa1

bbbb1

cccc1

dddd1

eeee1

aaaa2

bbbb2

cccc2

dddd2

eeee2

...

and so on, about 1500 times.

I need it to become

File0001.txt

aaaa1

bbbb1

cccc1

dddd1

eeee1

and so on till

File1500.txt

aaaa1500

bbbb1500

cccc1500

dddd1500

eeee1500

Does anybody know a FREEWARE tool to do this?

(I' ve tried "Replace Pioneer" all ready but I cant get it to work for some reason)

A Macro for MS Office 2007 would also work, if there is any...

Update:

@ Richard C

I searched for "split file" or sth.like that here with the Yahoo Answers search engine and it came up with a question similar to mine. There it was recommended to use the mentioned tool.

Update 2:

@ Stuart

Thanks for the script, but could you explain how to use it? I'm using Windows Vista; Python is installed, but I'm not familiar with it.

I put the script into a .py-file but how to go on now?

@ninin1922

Ich weiss noch nicht wie gross es effektiv wird, ich habe es noch nicht erstellt, wenn ich keinen Weg finde es später aufzusplitten, muss ich eh eine andere Lösung suchen.

Update 3:

@stuart:

I did so, and a black window was flickering, but nothing else happened.

4 Antworten

Relevanz
  • Anonym
    vor 1 Jahrzehnt
    Beste Antwort

    I wrote it really quickly in 17 lines of Python:

    http://pastebin.com/f161cef65

    Edit: To use it, put it in the same directory as Main.txt and then run 'python split.py' it will write out a bunch of files named File1.txt, File2.txt etc.

  • vor 1 Jahrzehnt

    If you're working in a Unix-based system you can use the split command from a terminal window.

    For example:

    split -l 5 -d -a 4 Main.txt File

    ...would split the file "Main.txt" into a bunch of 5-line files with file names like "File0000", "File0001", etc.

  • vor 1 Jahrzehnt

    What kind of FREEWARE tool were you expecting to find? "Text-splitter-into-separate-files-based-on-numerical-text-suffix"? Why would searching for "Replace Pioneer" give you the result you're looking for?

    Sounds like you need to create a simple perl script to do this.

  • vor 1 Jahrzehnt

    erst mal ne frage -- wieviel schaut da heraus ? - ueber 1 k

Haben Sie noch Fragen? Jetzt beantworten lassen.