Sponsored Content
Full Discussion: Scripting using flat files
Top Forums Programming Scripting using flat files Post 302519218 by fpmurphy on Tuesday 3rd of May 2011 10:54:03 AM
Old 05-03-2011
One possible solution would be to sort both files and use the join utlity.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Flat Files

I have a flat file like this 0001 THER ULT HEAD & NECK VES 0002 THER ULTRASOUND OF HEART 0003 THER ULT PERIPHERAL VES 0009 OTHER THERAPEUTIC ULTSND 0010 IMPLANT CHEMOTHERA AGENT 0011 INFUS DROTRECOGIN ALFA 0012 ADM INHAL NITRIC OXIDE I need to conver this to a comma delimited flat file... (2 Replies)
Discussion started by: thumsup9
2 Replies

2. Shell Programming and Scripting

Compare 2 flat files

Hi Gurus, I searched the forum but didnt get much info. I want to compare 2 files. 1)Newfile comes today with 2)Old file of previous day. The files are same ,just the new files might have new records sometimes. So I want to capture these new records in another file. Can anyone help... (5 Replies)
Discussion started by: ganesh123
5 Replies

3. Shell Programming and Scripting

Removing asterix (*) from flat files

Hi all, I have to generate a tab-delimited flat file. Since few days, I have been getting * in random accounts. For example, an account supposed to have the value 123456789123,123 Now this is supposed to be in a 12,3 format. Please note that this being a German field, the comma (,) here... (3 Replies)
Discussion started by: ctrl_alt_del
3 Replies

4. UNIX for Advanced & Expert Users

how read the flat files from shell scripting

We are using sybase data base and we have the data base name called MasterDB. The data baase MasterDB contains 100's of tables like sample1, sample2, sample3...etc...sample100 To take the count of every table we have to execute the following commands use MasterDB //DB name go //execute... (1 Reply)
Discussion started by: shijoe
1 Replies

5. Shell Programming and Scripting

how read the flat files from shell scripting

We are using sybase data base and we have the data base name called MasterDB. The data baase MasterDB contains 100's of tables like sample1, sample2, sample3...etc...sample100 To take the count of every table we have to execute the following commands use MasterDB //DB name go //execute... (1 Reply)
Discussion started by: shijoe
1 Replies

6. Shell Programming and Scripting

Getting Rid of Having to Write to Flat Files

Ok, so i've been having to write to flat files lately and then making my script read information from the flat file and then work off of that. i dont want to keep doing that because i believe it creates a mess. i like to keep my work all to one script instead of having that one script... (7 Replies)
Discussion started by: SkySmart
7 Replies

7. Shell Programming and Scripting

reading fixed length flat file and calling java code using shell scripting

I am new to shell scripting and I have to to the following I have a flat file with storename(lenth 20) , emailaddress(lenth 40), location(15). There is NO delimiters in that file. Like the following str00001.txt StoreName emailaddress location... (3 Replies)
Discussion started by: willywilly
3 Replies

8. Shell Programming and Scripting

Compare 2 flat files

Hi Frnds, I have a flat file with millions of records. . Now I on this. (I prefer for AWK as its gives good performance.) Old_file.txt ------------------ 1 gopi ase .... 2 arun pl ... 3 jack sutha .. 4 peter pm .. ... New_file.txt --------------- 4 peter pm .. .. ... (12 Replies)
Discussion started by: Gopal_Engg
12 Replies

9. Shell Programming and Scripting

How to add trailer record at the end of the flat file in the unix ksh shell scripting?

Hi, How to add trailer record at the end of the flat file in the unix ksh shell scripting can you please let me know the procedure Regards Srikanth (3 Replies)
Discussion started by: srikanth_sagi
3 Replies

10. Shell Programming and Scripting

Converting Multiline Files to Flat Files?

How to convert this: F1-R1 F1-R2 F1-R3 into a flat file for bash?? Each record F2-R1 F2-R2 F2-R3 F3-R1 F3-R2 F3-R3 F4-R1 F4-R2 F4-R3is on one line with all fields for that record, put into an output file. The output file should look like this when converted: F1-R1,F2-R1,F3-R1,F4-R1... (6 Replies)
Discussion started by: bud1738
6 Replies
File::Flat(3pm) 					User Contributed Perl Documentation					   File::Flat(3pm)

NAME
File::Flat - Implements a flat filesystem SYNOPSIS
DESCRIPTION
File::Flat implements a flat filesystem. A flat filesystem is a filesystem in which directories do not exist. It provides an abstraction over any normal filesystem which makes it appear as if directories do not exist. In effect, it will automatically create directories as needed. This is create for things like install scripts and such, as you never need to worry about the existance of directories, just write to a file, no matter where it is. Comprehensive Implementation The implementation of File::Flat is extremely comprehensive in scope. It has methods for all stardard file interaction taks, the -X series of tests, and some other things, such as slurp. All methods are statically called, for example, to write some stuff to a file. use File::Flat; File::Flat->write( 'filename', 'file contents' ); Use of other modules File::Flat tries to use more task orientated modules wherever possible. This includes the use of File::Copy, File::Copy::Recursive, File::Remove and others. These are mostly loaded on-demand. Pruning and $AUTO_PRUNE "Pruning" is a technique where empty directories are assumed to be useless, and thus empty removed whenever one is created. Thus, when some other task has the potential to leave an empty directory, it is checked and deleted if it is empty. By default File::Flat does not prune, and pruning must be done explicitly, via either the "prune" in File::Flat method, or by setting the second argument to the "remove" in File::Flat method to be true. However by setting the global $AUTO_PRUNE variable to true, File::Flat will automatically prune directories at all times. You should generally use this locally, such as in the following example. #!/usr/bin/perl use strict; use File::Flat; delete_files(@ARGV); exit(); # Recursively delete and prune all files provided on the command line sub delete_files { local $File::Flat::AUTO_PRUNE = 1; foreach my $file ( @_ ) { File::Flat->remove( $file ) or die "Failed to delete $file"; } } Non-Unix platforms As of version 0.97 File::Flat should work correctly on Win32. Other platforms (such as VMS) are believed to work, but require confirmation. METHODS
exists $filename Tests for the existance of the file. This is an exact duplicate of the -e function. isaFile $filename Tests whether "filename" is a file. This is an exact duplicate of the -f function. isaDirectory $filename Test whether "filename" is a directory. This is an exact duplicate of the -d function. canRead $filename Does the file or directory exist, and can we read from it. canWrite $filename Does the file or directory exist, and can we write to it OR can we create the file or directory. canReadWrite $filename Does a file or directory exist, and can we both read and write it. canExecute $filename Does a file or directory exist, and can we execute it. canOpen $filename Is this something we can open a filehandle to. Returns true if filename exists, is a file, and we can read from it. canRemove $filename Can we remove the file or directory. isaText $filename Does the file "filename" exist, and is it a text file. isaBinary $filename Does the file "filename" exist, and is it a binary file. fileSize $filename If the file exists, returns its size in bytes. Returns undef if the file does not exist. open [ $mode, ] $filename Rough analogue of the open function, but creates directories on demand as needed. Supports most of the normal options to the normal open function. In the single argument form, it takes modes in the form [mode]filename. For example, all the following are valid. File::Flat->open( 'filename' ); File::Flat->open( '<filename' ); File::Flat->open( '>filename' ); File::Flat->open( '>>filename' ); File::Flat->open( '+<filename' ); In the two argument form, it takes the following File::Flat->open( '<', 'filename' ); File::Flat->open( '>', 'filename' ); File::Flat->open( '>>', 'filename' ); File::Flat->open( '+<', 'filename' ); It does not support the more esoteric forms of open, such us opening to a pipe or other such things. On successfully opening the file, it returns it as an IO::File object. Returns undef on error. getReadHandle $filename The same as File::Flat->open( '<', 'filename' ) getWriteHandle $filename The same as File::Flat->open( '>', 'filename' ) getAppendHandle $filename The same as File::Flat->open( '>>', 'filename' ) getReadWriteHandle $filename The same as File::Flat->open( '+<', 'filename' ) read $filename Opens and reads in an entire file, chomping as needed. In array context, it returns an array containing each line of the file. In scalar context, it returns a reference to an array containing each line of the file. It returns undef on error. slurp $filename The "slurp" method 'slurps' a file in. That is it attempts to read the entire file into a variable in as quick and memory efficient method as possible. On success, returns a reference to a scalar, containing the entire file. Returns undef on error. write $filename, ( $content | $content | @content ) The "write" method is the main method for writing content to a file. It takes two arguments, the location to write to, and the content to write, in several forms. If the file already exists, it will be clobered before writing starts. If the file doesn't exists, the file and any directories will be created as needed. Content can be provided in three forms. The contents of a scalar argument will be written directly to the file. You can optionally pass a reference to the scalar. This is recommended when the file size is bigger than a few thousand characters, is it does not duplicate the file contents in memory. Alternatively, you can pass the content as a reference to an array containing the contents. To ensure uniformity, "write" will add a newline to each line, replacing any existing newline as needed. Returns true on success, and undef on error. append $filename, ( $content | $content | @content ) This method is the same as "write", except that it appends to the end of an existing file ( or creates the file as needed ). This is the method you should be using to write to log files, etc. overwrite $filename, ( $content | $content | @content ) Performs an atomic write over a file. It does this by writing to a temporary file, and moving the completed file over the top of the existing file ( or creating a new file as needed ). When writing to a file that is on the same partition as /tmp, this should always be atomic. This method otherwise acts the same as "write". copy $source, $target The "copy" method attempts to copy a file or directory from the source to the target. New directories to contain the target will be created as needed. For example "<File::Flat-"( './this', './a/b/c/d/that' );>> will create the directory structure required as needed. In the file copy case, if the target already exists, and is a writable file, we replace the existing file, retaining file mode and owners. If the target is a directory, we do NOT copy into that directory, unlike with the 'cp' unix command. And error is instead returned. "copy" will also do limited recursive copying or directories. If source is a directory, and target does not exists, a recursive copy of source will be made to target. If target already exists ( file or directory ), "copy" will returns with an error. move $source, $target The "move" method follows the conventions of the 'mv' command, with the exception that the directories containing target will of course be created on demand. remove $filename [, $prune ] The "remove" method will remove a file, or recursively remove a directory. If a second (true) argument is provided, then once the file or directory has been deleted, the method will the automatically work its way upwards pruning (deleting) empty and thus assumably useless directories. Returns true if the deletion (and pruning if requested) was a success, or "undef" otherwise. prune $filename For a file that has already been delete, "prune" will work upwards, removing any empty directories it finds. For anyone familiar with CVS, it is similar to the "update -P" flag. Returns true, or "undef" on error. truncate $filename [, $size ] The "truncate" method will truncate an existing file to partular size. A size of 0 ( zero ) is used if no size is provided. If the file does not exists, it will be created, and set to 0. Attempting to truncate a directory will fail. Returns true on success, or undef on error. makeDirectory $directory [, mode ] In the case where you do actually have to create a directory only, the "makeDirectory" method can be used to create a directory or any depth. An optional file mode ( default 0755 ) can be provided. Returns true on success, returns undef on error. TO DO
Function interface to be written, like File::Spec::Functions, to provide importable functions. There's something bigger here too, I'm not exactly sure what it is, but I think there might be the beginings of a unified filesystem interface here... FSI.pm SUPPORT
Bugs should be filed at via the CPAN bug tracker at: http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Flat <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Flat> For other issues or comments, contact the author AUTHORS
Adam Kennedy <adamk@cpan.org> SEE ALSO
File::Spec, <http://ali.as/> COPYRIGHT
Copyright 2002 - 2008 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.14.2 2008-03-24 File::Flat(3pm)
All times are GMT -4. The time now is 12:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy