- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- comma delimited file - and carriage return
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 07:41 AM
тАО03-19-2009 07:41 AM
adultid,firstname,lastname,homeaddress,city,state,zip,location,
For some reason I transfer the file and it appears the data is contained in one long line..
I need to append a End of Line each record of the file.. Any ideas appreciated..
Solved! Go to Solution.
- Tags:
- csv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 08:01 AM
тАО03-19-2009 08:01 AM
Re: comma delimited file - and carriage return
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 08:06 AM
тАО03-19-2009 08:06 AM
SolutionUsing 'od' (or 'xd' which is an "alias" hardlink) or using 'cat -ev' might help expose any linecontrols.
That said, how would you define "record"? If it's a bare carriage-return delimiter (which is what I suspect), one way to fix it is to do:
# perl -pe 's/\015/\012/g' file
Regards!
...JRF...
- Tags:
- xd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 08:07 AM
тАО03-19-2009 08:07 AM
Re: comma delimited file - and carriage return
For record:
adultid,firstname,lastname,homeaddress,city,state,zip,location,
1234,Joe,smith,1234 main,Omaha,NE,68128,Building10,
1235,John,Doe,4321 Main,Omaha,NE,68128,Building20,
and so on after each "location" (noted in the header..)..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 08:14 AM
тАО03-19-2009 08:14 AM
Re: comma delimited file - and carriage return
for a file like
cat /tmp/b
adultid,firstname,lastname,homeaddress,city,state,zip,location,adultid,firstname,lastname,homeaddress,city,state,zip,location,adultid,firstname,lastname,homeaddress,city,state,zip,location,adultid,firstname,lastname,homeaddress,city,state,zip,location
I would do a
awk '{gsub("location,"location,"location\n");print}' /tmp/b
Output as
awk '{gsub("location,"location,"location\n");print}' /tmp/b
adultid,firstname,lastname,homeaddress,city,state,zip,location
adultid,firstname,lastname,homeaddress,city,state,zip,location
adultid,firstname,lastname,homeaddress,city,state,zip,location
adultid,firstname,lastname,homeaddress,city,state,zip,location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 08:18 AM
тАО03-19-2009 08:18 AM
Re: comma delimited file - and carriage return
For some reason informix is outputting EOL as tab, rather then new line..
I did an inline edit perl -pi -e ......
I am waiting for the client to reply to see if their application accepted the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 08:31 AM
тАО03-19-2009 08:31 AM
Re: comma delimited file - and carriage return
> For some reason informix is outputting EOL as tab, rather then new line..
If substituting \012 and \015 worked it would have been faster to use 'tr':
# perl -pe 'tr/\015/\012/' file
The same would have applied for a TAB which is \011.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 09:06 AM
тАО03-19-2009 09:06 AM
Re: comma delimited file - and carriage return
...and I should add that if the only need is a translation of one character to another, we could easily use a pure shell:
# tr "\015" "\012" < file > file.new
# mv file.new file.old
...but then we couldn't have done inplace updates (as you already did) as with:
# perl -pi.old -e 'tr/\015/\012/' file
...leaving a backup copy as "file.old".
Of course, we could use GNU's 'sed' to perform substitutions and inplace edits, but then Perl is so much more fun and scales easily :-)
Regards!
...JRF...