Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Creating a csv file with header in UNIX Post 302795133 by Yoda on Wednesday 17th of April 2013 10:14:17 AM
Old 04-17-2013
The code uses a Conditional Expression to construct variables: f1 & f2 values

If f1 is defined, then append f1 value with comma , and first field $1 and assign to f1 else assign first field $1. Similarly for f2 but using second field $2.

In the END block, print variable values.
This User Gave Thanks to Yoda For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating a csv file in awk

Hi All I am trying to create a csv file in the korn shell and the script segment is as follows: if then # NEED TO ADD INFO TO THE EMAIL FILE ABOUT THE DRIVE THAT'S FILLING UP echo "$drive $percent% $space "|\ awk '{printf("%d/t"|"%d/t"|"%d/t\n",... (6 Replies)
Discussion started by: Segwar
6 Replies

2. Shell Programming and Scripting

How can I add a header to a csv file

I have a csv file which has no header. the file has 15 fields and needs to go out with a header of 8 fields. The header content needs to have some variables and some fixed that i have set up: variable header fields OUTFILE_YEAR=`date '+%y'` DATE=`date '+%d%m%y'` TIME=`date '+%H:%M:%S'`... (6 Replies)
Discussion started by: Pablo_beezo
6 Replies

3. Shell Programming and Scripting

Append Header in CSV file

Hi, I create a csv file and the output looks like below Arun,E001 Sathish,E003 Now i need to include the below header and the output should like below Name,Number Arun,E001 Sathish,E003 Please guide me. Thanks (4 Replies)
Discussion started by: Sekar1
4 Replies

4. Shell Programming and Scripting

Creating Header & Trailer for bulk volume data file

Hi all, I have a requirement to create a Header &Trailer for a file which is having 20 millions of records. If I use the following method, i think it will take more time. cat "Header"> file1.txt cat Data_File>>file1.txt cat "Trailer">>file1.txt since second CAT command has to read all... (4 Replies)
Discussion started by: Raamc
4 Replies

5. Shell Programming and Scripting

Add header to a .csv file

Hi, I am trying to add a header record to all the .csv files in a directory. I am using the below sed commnad sed -i '1 i \abc,sam,xyz,tip,pep,rip' xyz.csv but this is not adding the header and I am not getting any error,pls tell me if any thing is wrong in the code. Thanks, Shruthi (2 Replies)
Discussion started by: shruthidwh
2 Replies

6. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

7. Shell Programming and Scripting

How to get sqlplus column header once in csv file?

Hi All, Could anyoone please let me know how do I get sqlplus column header once in csv file Scripts are below: cat concreq.sh #!/bin/bash . $HOME/.profile while ; do sqlplus apps/pwd <<-EOF set lines 100 pages 100 col "USER_CONCURRENT_QUEUE_NAME" format a40; --set termout off... (5 Replies)
Discussion started by: a1_win
5 Replies

8. Shell Programming and Scripting

Creating your own Header file in awk

whether it is possible in awk to create your own header file like in C if so someone give me awk equivalent for below one $ cat foo.h int add(int a,int b) { return(a+b); } $ cat main.c #include<stdio.h> #include"foo.h" void main() { int number1=10,number2=10,number3; number3 =... (5 Replies)
Discussion started by: Akshay Hegde
5 Replies

9. Shell Programming and Scripting

Matching the header of a .CSV file with dynamic field names

I have a .CSV file (frequency - weekly) whose header contains the year-week value in two of the columns which keeps changing every week. For an instance please see below. Column1,Column2,Column3,Column4,Column5,Column6,Column7,Column8,Column9,Column10,Column11,Column12,Column13,201420... (4 Replies)
Discussion started by: dhruuv369
4 Replies

10. Shell Programming and Scripting

Script to validate header in a csv file

Hi All; I am struggling to write a script that validates file header. Header file would be like below with TAB separated TRX # TYPE REF # Source Piece Code Destination Piece Code every time I need to check the txt file if the header was same as above fields if validation success... (6 Replies)
Discussion started by: heye18
6 Replies
Module::Load::Conditional(3pm)				 Perl Programmers Reference Guide			    Module::Load::Conditional(3pm)

NAME
Module::Load::Conditional - Looking up module information / loading at runtime SYNOPSIS
use Module::Load::Conditional qw[can_load check_install requires]; my $use_list = { CPANPLUS => 0.05, LWP => 5.60, 'Test::More' => undef, }; print can_load( modules => $use_list ) ? 'all modules loaded successfully' : 'failed to load required modules'; my $rv = check_install( module => 'LWP', version => 5.60 ) or print 'LWP is not installed!'; print 'LWP up to date' if $rv->{uptodate}; print "LWP version is $rv->{version} "; print "LWP is installed as file $rv->{file} "; print "LWP requires the following modules to be installed: "; print join " ", requires('LWP'); ### allow M::L::C to peek in your %INC rather than just ### scanning @INC $Module::Load::Conditional::CHECK_INC_HASH = 1; ### reset the 'can_load' cache undef $Module::Load::Conditional::CACHE; ### don't have Module::Load::Conditional issue warnings -- ### default is '1' $Module::Load::Conditional::VERBOSE = 0; ### The last error that happened during a call to 'can_load' my $err = $Module::Load::Conditional::ERROR; DESCRIPTION
Module::Load::Conditional provides simple ways to query and possibly load any of the modules you have installed on your system during runtime. It is able to load multiple modules at once or none at all if one of them was not able to load. It also takes care of any error checking and so forth. Methods $href = check_install( module => NAME [, version => VERSION, verbose => BOOL ] ); "check_install" allows you to verify if a certain module is installed or not. You may call it with the following arguments: module The name of the module you wish to verify -- this is a required key version The version this module needs to be -- this is optional verbose Whether or not to be verbose about what it is doing -- it will default to $Module::Load::Conditional::VERBOSE It will return undef if it was not able to find where the module was installed, or a hash reference with the following keys if it was able to find the file: file Full path to the file that contains the module dir Directory, or more exact the @INC entry, where the module was loaded from. version The version number of the installed module - this will be "undef" if the module had no (or unparsable) version number, or if the variable $Module::Load::Conditional::FIND_VERSION was set to true. (See the "GLOBAL VARIABLES" section below for details) uptodate A boolean value indicating whether or not the module was found to be at least the version you specified. If you did not specify a version, uptodate will always be true if the module was found. If no parsable version was found in the module, uptodate will also be true, since "check_install" had no way to verify clearly. See also $Module::Load::Conditional::DEPRECATED, which affects the outcome of this value. $bool = can_load( modules => { NAME => VERSION [,NAME => VERSION] }, [verbose => BOOL, nocache => BOOL] ) "can_load" will take a list of modules, optionally with version numbers and determine if it is able to load them. If it can load *ALL* of them, it will. If one or more are unloadable, none will be loaded. This is particularly useful if you have More Than One Way (tm) to solve a problem in a program, and only wish to continue down a path if all modules could be loaded, and not load them if they couldn't. This function uses the "load" function from Module::Load under the hood. "can_load" takes the following arguments: modules This is a hashref of module/version pairs. The version indicates the minimum version to load. If no version is provided, any version is assumed to be good enough. verbose This controls whether warnings should be printed if a module failed to load. The default is to use the value of $Module::Load::Conditional::VERBOSE. nocache "can_load" keeps its results in a cache, so it will not load the same module twice, nor will it attempt to load a module that has already failed to load before. By default, "can_load" will check its cache, but you can override that by setting "nocache" to true. @list = requires( MODULE ); "requires" can tell you what other modules a particular module requires. This is particularly useful when you're intending to write a module for public release and are listing its prerequisites. "requires" takes but one argument: the name of a module. It will then first check if it can actually load this module, and return undef if it can't. Otherwise, it will return a list of modules and pragmas that would have been loaded on the module's behalf. Note: The list "require" returns has originated from your current perl and your current install. Global Variables The behaviour of Module::Load::Conditional can be altered by changing the following global variables: $Module::Load::Conditional::VERBOSE This controls whether Module::Load::Conditional will issue warnings and explanations as to why certain things may have failed. If you set it to 0, Module::Load::Conditional will not output any warnings. The default is 0; $Module::Load::Conditional::FIND_VERSION This controls whether Module::Load::Conditional will try to parse (and eval) the version from the module you're trying to load. If you don't wish to do this, set this variable to "false". Understand then that version comparisons are not possible, and Module::Load::Conditional can not tell you what module version you have installed. This may be desirable from a security or performance point of view. Note that $FIND_VERSION code runs safely under "taint mode". The default is 1; $Module::Load::Conditional::CHECK_INC_HASH This controls whether "Module::Load::Conditional" checks your %INC hash to see if a module is available. By default, only @INC is scanned to see if a module is physically on your filesystem, or available via an "@INC-hook". Setting this variable to "true" will trust any entries in %INC and return them for you. The default is 0; $Module::Load::Conditional::CACHE This holds the cache of the "can_load" function. If you explicitly want to remove the current cache, you can set this variable to "undef" $Module::Load::Conditional::ERROR This holds a string of the last error that happened during a call to "can_load". It is useful to inspect this when "can_load" returns "undef". $Module::Load::Conditional::DEPRECATED This controls whether "Module::Load::Conditional" checks if a dual-life core module has been deprecated. If this is set to true "check_install" will return false to "uptodate", if a dual-life module is found to be loaded from $Config{privlibexp} The default is 0; See Also "Module::Load" BUG REPORTS
Please report bugs or other issues to <bug-module-load-conditional@rt.cpan.org>. AUTHOR
This module by Jos Boumans <kane@cpan.org>. COPYRIGHT
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. perl v5.18.2 2014-01-06 Module::Load::Conditional(3pm)
All times are GMT -4. The time now is 02:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy