Create file per country
Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators
Create file per country
Another small problem:
Format:
1001|First Company|USA|First Address|other fields
I have several hundreds of files with random filename with this format.
I would like to create USA.dump file and UK.dump file etc per each country found in all files.
I made extract with all Country names and removed duplicates and sorted.
Now how can I automatic create files USA.dump with all data from USA in this file and for all other countries found?
(I hope my question is clear)
Added:
So I want to end up with USA.dump UK.dump CANADA.dump etc (each file containing the data belonging to the country, so first line in USA.dump would be: 1001|First Company|USA|First Address|other fields..
CRAIGER
Format:
1001|First Company|USA|First Address|other fields
I have several hundreds of files with random filename with this format.
I would like to create USA.dump file and UK.dump file etc per each country found in all files.
I made extract with all Country names and removed duplicates and sorted.
Now how can I automatic create files USA.dump with all data from USA in this file and for all other countries found?
(I hope my question is clear)
Added:
So I want to end up with USA.dump UK.dump CANADA.dump etc (each file containing the data belonging to the country, so first line in USA.dump would be: 1001|First Company|USA|First Address|other fields..
CRAIGER
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Create file per country
Hi! I'm stupid! Can you try to make this in your program and then explain for dummy? Please!
in other words
i have file all.txt:
1001|First Company|USA|First Address
1002|Second Company|USA|Second Address
1004|First Company|UK|First Address
1007|2 Company|UK|2 Address
1008|3 Company|UK|3 Address
1008|67 Company|CA|43 Address
1008|23 Company|CA|63 Address
i need 3 files in output:
USA.txt:
1001|First Company|USA|First Address
1002|Second Company|USA|Second Address
UK.txt:
1004|First Company|UK|First Address
1007|2 Company|UK|2 Address
1008|3 Company|UK|3 Address
CA.txt:
1008|67 Company|CA|43 Address
1008|23 Company|CA|63 Address
in other words
i have file all.txt:
1001|First Company|USA|First Address
1002|Second Company|USA|Second Address
1004|First Company|UK|First Address
1007|2 Company|UK|2 Address
1008|3 Company|UK|3 Address
1008|67 Company|CA|43 Address
1008|23 Company|CA|63 Address
i need 3 files in output:
USA.txt:
1001|First Company|USA|First Address
1002|Second Company|USA|Second Address
UK.txt:
1004|First Company|UK|First Address
1007|2 Company|UK|2 Address
1008|3 Company|UK|3 Address
CA.txt:
1008|67 Company|CA|43 Address
1008|23 Company|CA|63 Address
Re: Create file per country
Forgot term:
Obviously, I have a list of coutries: USA, UK, CA
In which format enter them into "restrict to lines matching" line?
Obviously, I have a list of coutries: USA, UK, CA
In which format enter them into "restrict to lines matching" line?
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Create file per country
Just one country per line e..g
USA
UK
CA
USA
UK
CA
-
- Posts: 988
- Joined: Sun Dec 09, 2007 2:49 am
- Location: UK
Re: Create file per country
Surely this task was so simple it could have been done just by means of a CMD script using the Windows find command?Best regards,
David
Code: Select all
find "|USA|" <inputfile >USA.txt
find "|UK|" <inputfile >UK.txt
...etc
David
David
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Create file per country
With TextPipe you can perform the sort and remove duplicates, and the sending of the country-specific data, all in one step.
Code: Select all
|--Ascending ANSI sort (case sensitive), remove duplicates, length 4096
|
|--Restrict to lines matching [\|US\|]
| | [ ] Include line numbers
| | [ ] Include filename
| | [ ] Match case
| | [ ] Count matches
| | Pattern type: 1
| | Context before: 0
| | Context after: 0
| |
| |--Merge output to file c:\USA.txt
| |
| +--Remove all
|
|--Restrict to lines matching [\|UK\|]
| | [ ] Include line numbers
| | [ ] Include filename
| | [ ] Match case
| | [ ] Count matches
| | Pattern type: 1
| | Context before: 0
| | Context after: 0
| |
| |--Merge output to file c:\UK.txt
| |
| +--Remove all
|
..etc..