Hello everyone,
I would like to split an existing csv-file into multiple files by an in-file criteria - let's call it filename.
I already found a script for doing this by amount of lines in this forum - but as I am not a coder, I am unfortunately not able to translate this into my purposes.
Does anyone know how to solve this?
Thanks & regards,
Achim
split csv-file by in-file criteria
Moderator: DosItHelp
Re: split csv-file by in-file criteria
Describe your problem with examples - someone here can figure out the most appropriate and robust method to solve it.
Re: split csv-file by in-file criteria
Hi again,
for example, my csv-file contains the following rows:
record1;this is a test;filename1
record2;this is another test;filename2
record3;this is a 3rd test;filename1
record4;this is a 4th test;filename3
...
What I would like to get are 3 file containing the following records and named like the column filename (3rd column of file):
filename1:
record1;this is a test;filename1
record3;this is a 3rd test;filename1
filename2:
record2;this is another test;filename2
filename3:
record4;this is a 4th test;filename3
Is this somehow possible?
Thanks in advance & kind regards,
Achim
for example, my csv-file contains the following rows:
record1;this is a test;filename1
record2;this is another test;filename2
record3;this is a 3rd test;filename1
record4;this is a 4th test;filename3
...
What I would like to get are 3 file containing the following records and named like the column filename (3rd column of file):
filename1:
record1;this is a test;filename1
record3;this is a 3rd test;filename1
filename2:
record2;this is another test;filename2
filename3:
record4;this is a 4th test;filename3
Is this somehow possible?
Thanks in advance & kind regards,
Achim
Re: split csv-file by in-file criteria
Your request doesn't give enough information about which lines go into which files, unless your CSV file is really only 4 lines long.
Re: split csv-file by in-file criteria
try this
Code: Select all
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=1,2,3 delims=;" %%A in (test.csv) do @echo %%A;%%B;%%C >> %%C
Re: split csv-file by in-file criteria
That splits every record (and adds a space to the end).
The OP wants something a little different...
The OP wants something a little different...