Sponsored Content
Full Discussion: format output in csv file
Top Forums Shell Programming and Scripting format output in csv file Post 302369148 by Franklin52 on Friday 6th of November 2009 04:05:02 PM
Old 11-06-2009
Try this, suppose you want to replace the commas with spaces:

Code:
 awk 'BEGIN{printf("\"")}{gsub(","," ")}END{printf("\"")}1'  file.csv > newfile.csv

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

2. Shell Programming and Scripting

formatting into CSV format of SQL session output

I am getting a no of fields from a SQL session (e.g. select a,b,c from table). How do I convert the output values into CSV format . The output should be like this 'a','b','c', (4 Replies)
Discussion started by: mady135
4 Replies

3. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

4. Shell Programming and Scripting

Csv format output file using scirpt

Hi All, I get the test result file daily after running the main test script. from the resultfile, need to fetch only server info and status and put them in tabular format in a file and as well in CSV format output file. I tried using awk command but am not able to put them in tabluar... (6 Replies)
Discussion started by: Optimus81
6 Replies

5. Shell Programming and Scripting

UNIX command output in csv format

I'm just wondering is there any way to capture the output of a unix command in a csv format. df -h gives the result of filesystem,free space,Used space, use %,mounted on. Is there a way to capture the command output and format it as comma sparated or fixed length file. (3 Replies)
Discussion started by: anita81
3 Replies

6. Shell Programming and Scripting

Save output of updated csv file as csv file itself

Hi, all I want to sort a csv file based on timestamp from oldest to newest and save the output as csv file itself. Here is an example of my csv file. test.csv SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0739.JPG,2015:02:17 11:32:21 /home/intannf/foto/IMG_0749.JPG,2015:02:17 11:37:28... (10 Replies)
Discussion started by: refrain
10 Replies

7. Shell Programming and Scripting

Save output of updated csv file as csv file itself, part 2

Hi, I have another problem. I want to sort another csv file by the first field. result.csv SourceFile,Airspeed,GPSLatitude,GPSLongitude,Temperature,Pressure,Altitude,Roll,Pitch,Yaw /home/intannf/foto5/2015_0313_090651_219.JPG,0.,-7.77223,110.37310,30.75,996.46,148.75,180.94,182.00,63.92 ... (2 Replies)
Discussion started by: refrain
2 Replies

8. Shell Programming and Scripting

How to parse this file using awk and output in CSV format?

My source file looks like this: Cust-Number = "101" Cust-Name="Joe" Cust-Town="London" Cust-hobby="tennis" Cust-purchase="200" Cust-Number = "102" Cust-Name="Mary" Cust-Town="Newyork" Cust-hobby="reading" Cust-purchase="125" Now I want to parse this file (leaving out hobby) and... (10 Replies)
Discussion started by: Balav
10 Replies

9. Shell Programming and Scripting

How to translate df -h output into a CSV format?

Hi, Can someone please let me know as how I can send the below df -h format of a linux system into a CSV format ? Resource Size GiB Used GiB Avail GiB Use% Cleanable GiB* ---------------- -------- -------- --------- ---- -------------- /data: pre-comp -... (10 Replies)
Discussion started by: new2prog
10 Replies

10. Programming

Python or Shell script to Grep strings from input file and output in csv format

Hi Experts, I am writing a python script to grep string from file and display output in csv file as in attached screenshot https://drive.google.com/file/d/1gfUUdfmQma33tz65NskThYDhkZUGQO0H/view Input file(result_EPFT_config_device) Below is the python script i have prepared as of... (1 Reply)
Discussion started by: as7951
1 Replies
Df(3pm) 						User Contributed Perl Documentation						   Df(3pm)

NAME
Filesys::Df - Perl extension for filesystem disk space information. SYNOPSIS
use Filesys::Df; #### Get information by passing a scalar directory/filename value my $ref = df("/tmp"); # Default output is 1K blocks if(defined($ref)) { print "Total 1k blocks: $ref->{blocks} "; print "Total 1k blocks free: $ref->{bfree} "; print "Total 1k blocks avail to me: $ref->{bavail} "; print "Total 1k blocks used: $ref->{used} "; print "Percent full: $ref->{per} "; if(exists($ref->{files})) { print "Total inodes: $ref->{files} "; print "Total inodes free: $ref->{ffree} "; print "Inode percent full: $ref->{fper} "; } } #### Get information by passing a filehandle open(FILE, "some_file"); # Get information for filesystem at "some_file" my $ref = df(*FILE); #### or my $ref = df(*FILE); #### or my $fhref = *FILE; my $ref = df($fhref); #### Get information in other than 1k blocks my $ref = df("/tmp", 8192); # output is 8K blocks my $ref = df("/tmp", 1); # output is bytes DESCRIPTION
This module provides a way to obtain filesystem disk space information. This is a Unix only distribution. If you want to gather this information for Unix and Windows, use "Filesys::DfPortable". The only major benefit of using "Filesys::Df" over "Filesys::DfPortable", is that "Filesys::Df" supports the use of open filehandles as arguments. The module should work with all flavors of Unix that implement the "statvfs()" and "fstatvfs()" calls, or the "statfs()" and "fstatfs()" calls. This would include Linux, *BSD, HP-UX, AIX, Solaris, Mac OS X, Irix, Cygwin, etc ... "df()" requires a argument that represents the filesystem you want to query. The argument can be either a scalar directory/file name or a open filehandle. There is also an optional block size argument so you can tailor the size of the values returned. The default block size is 1024. This will cause the function to return the values in 1k blocks. If you want bytes, set the block size to 1. "df()" returns a reference to a hash. The keys available in the hash are as follows: "{blocks}" = Total blocks on the filesystem. "{bfree}" = Total blocks free on the filesystem. "{bavail}" = Total blocks available to the user executing the Perl application. This can be different than "{bfree}" if you have per-user quotas on the filesystem, or if the super user has a reserved amount. "{bavail}" can also be a negative value because of this. For instance if there is more space being used then you have available to you. "{used}" = Total blocks used on the filesystem. "{per}" = Percent of disk space used. This is based on the disk space available to the user executing the application. In other words, if the filesystem has 10% of its space reserved for the superuser, then the percent used can go up to 110%. You can obtain inode information through the module as well, but you must call "exists()" on the "{files}" key first, to make sure the information is available. Some filesystems may not return inode information, for example some NFS filesystems. Here are the available inode keys: "{files}" = Total inodes on the filesystem. "{ffree}" = Total inodes free on the filesystem. "{favail}" = Total inodes available to the user executing the application. See the rules for the "{bavail}" key. "{fused}" = Total inodes used on the filesystem. "{fper}" = Percent of inodes used on the filesystem. See rules for the "{per}" key. There are some undocumented keys that are defined to maintain backwards compatibilty: "{su_blocks}", "{user_blocks}", etc ... If the "df()" call fails for any reason, it will return undef. This will probably happen if you do anything crazy like try to get information for /proc, or if you pass an invalid filesystem name, or if there is an internal error. "df()" will "croak()" if you pass it a undefined value. Requirements: Your system must contain "statvfs()" and "fstatvfs()", or "statfs()" and "fstatfs()" You must be running Perl 5.6 or higher. AUTHOR
Ian Guthrie IGuthrie@aol.com Copyright (c) 2006 Ian Guthrie. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
statvfs(2), fstatvfs(2), statfs(2), fstatfs(2), df(1), Filesys::DfPortable perl(1). perl v5.14.2 2006-06-25 Df(3pm)
All times are GMT -4. The time now is 12:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy