- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH ...
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
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
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
тАО11-13-2008 12:06 PM
тАО11-13-2008 12:06 PM
CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH FILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2008 12:34 PM
тАО11-13-2008 12:34 PM
Re: CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH FILE
Given a file like this:
"a","b","c"
"aa","bb","cc"
"AaA","BbB","CcC"
I assume that (for whatever reason) you want to pad out with trailing spaces. Then you could do (for example to make 40-character records) is:
# perl -ple '$_.= "-" x (40-length($_))' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2008 12:41 PM
тАО11-13-2008 12:41 PM
Re: CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH FILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2008 12:45 PM
тАО11-13-2008 12:45 PM
Re: CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH FILE
> Let me clarify my question.. Is there a command that will convert a COMMA DELIMITED FILE (CSV) to a fixed column length file in UNIX?
What's wrong with the *command* I wrote?
Substitute whatever value you want for '40' to gain the desired fixed line length.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2008 12:51 PM
тАО11-13-2008 12:51 PM
Re: CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH FILE
Example: I have a file with 4 fields I want the starting position in the same position.
Current file:
12121,XXX,ZZZZZ,Z
1212,XX,ZZZZ,Z
The results I would like is:
12121,XXX,ZZZZZ,Z
1212 ,XX ,ZZZZ ,Z
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2008 01:17 PM
тАО11-13-2008 01:17 PM
Re: CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH FILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2008 01:18 PM
тАО11-13-2008 01:18 PM
Re: CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH FILE
Oh, OK. How about this (adjust the field widths as necessary):
# perl -ne 'chomp;@F=split /,/;printf "%-12s,%-12s,%-12s\n",@F' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-14-2008 02:22 AM
тАО11-14-2008 02:22 AM
Re: CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH FILE
Typically if you have fixed fields, you don't need the commas.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-14-2008 04:48 AM
тАО11-14-2008 04:48 AM
Re: CONVERTING A COMMA DELIMITED FILE TO FIXED LENGTH FILE
'tr'
Otherwise as the master said
some handy oneliners
with perl or sed or awk.
google is your best friend :├В┬░)