Extract data from a csv file and save in a new file
Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
2 posts
Page 1 of 1
- Posts: 9
- Joined: Thu May 15, 2014 10:47 am
Hi,
We have a requirement to split a csv (|) file into multiple files based on data in file
For example all lines with code "A100" goes to a file with name "A100_extract"
and all lines with code "A200" goes to another file with name "A200_extract"
Is this possible to do in director?
Thanks
We have a requirement to split a csv (|) file into multiple files based on data in file
For example all lines with code "A100" goes to a file with name "A100_extract"
and all lines with code "A200" goes to another file with name "A200_extract"
Is this possible to do in director?
Thanks
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
Nishant,
This situation is a good reason why the modifyRowset Task was added to GoAnywhere Director in version 4.6. Below, I provided an example of how this can be accomplished utilizing that task.
Data
Please let us know if you have any other questions..
This situation is a good reason why the modifyRowset Task was added to GoAnywhere Director in version 4.6. Below, I provided an example of how this can be accomplished utilizing that task.
Data
Code: Select all
A101| Field 2| Field 3| Field 4| Field 5
A101| Field 2| Field 3| Field 4| Field 5
A102| Field 2| Field 3| Field 4| Field 5
A102| Field 2| Field 3| Field 4| Field 5
A101| Field 2| Field 3| Field 4| Field 5
A102| Field 2| Field 3| Field 4| Field 5
A101| Field 2| Field 3| Field 4| Field 5
A102| Field 2| Field 3| Field 4| Field 5
A101| Field 2| Field 3| Field 4| Field 5
Code: Select all
If your unique "known" values (from column 1) are available via a rowset (read from a Table, or CSV, etc) you could easily do this inside a ForEach loop and substitute the compare values with variables.<project name="Filter Pipe Delimited File" mainModule="Main" version="2.0" logLevel="debug">
<module name="Main">
<readCSV label="Read PIPE file" inputFile="C:\Pipe Delimited File.csv" outputRowSetVariable="MyData" fieldDelimiter="pipe" version="1.0" />
<modifyRowSet label="Create A101 Rowset" inputRowSetVariable="${MyData}" outputRowSetVariable="MyA101Data" existingColumns="true" includeRow="${MyData[1] == 'A101'}" version="1.0">
<modifyColumn index="1" name="C1" value="${MyData[1]}" />
</modifyRowSet>
<modifyRowSet label="Create A102 Rowset" inputRowSetVariable="${MyData}" outputRowSetVariable="MyA102Data" existingColumns="true" includeRow="${MyData[1] == 'A102'}" version="1.0">
<modifyColumn index="1" name="C1" value="${MyData[1]}" />
</modifyRowSet>
<writeCSV label="Create A101 File" inputRowSetVariable="${MyA101Data}" outputFile="C:\MyA101Data.csv" whenFileExists="overwrite" fieldDelimiter="pipe" version="1.0" />
<writeCSV label="Create A102 File" inputRowSetVariable="${MyA102Data}" outputFile="C:\MyA102Data.csv" whenFileExists="overwrite" fieldDelimiter="pipe" version="1.0" />
</module>
</project>
Please let us know if you have any other questions..
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
2 posts
Page 1 of 1