Sponsored Content
Full Discussion: Flat File to HTML
Top Forums UNIX for Dummies Questions & Answers Flat File to HTML Post 302106538 by Glenn Arndt on Friday 9th of February 2007 09:37:16 AM
Old 02-09-2007
You can make a quick-and-dirty HTML document containing preformatted text from your text file, e.g.:
Code:
{
  print "<html><head><title>My Title Here<title></head><body><pre>"
  cat file.txt
  print "</pre></body></html>"
} > file.html

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help to convert Flat file to HTML

Hello I need help to convert flat file data to HTML Table format. I am generating everyday Flat file and want to convert into HTML Table format. The format of my file is: version host Total YRS NO APPS PSD 10 Sun 30 2 4 6 7 and flat... (11 Replies)
Discussion started by: getdpg
11 Replies

2. Shell Programming and Scripting

Help with a flat file!!!

Hi All, I get a flat file everyday with some records being invalid.Some records come with less number '|'.I just want to add the missing '|'s ,So the it doesnt give an error insufficient fields while loading...There area total of 32 pipes in each record. Input: ASADASD |Y|B|SDFGDSDFD| ... (3 Replies)
Discussion started by: kumarsaravana_s
3 Replies

3. Shell Programming and Scripting

Help with a Flat File!!!

Hi All, I need a help with a shelll script program.I get a '|' separated file which sometime has a encrypted column.And this encryption sometime breaks the last column data into a new line and this is not picked by the ETL.So when i run a script,it should append back the broken new line data... (11 Replies)
Discussion started by: kumarsaravana_s
11 Replies

4. UNIX for Dummies Questions & Answers

How do I extract text only from html file without HTML tag

I have a html file called myfile. If I simply put "cat myfile.html" in UNIX, it shows all the html tags like <a href=r/26><img src="http://www>. But I want to extract only text part. Same problem happens in "type" command in MS-DOS. I know you can do it by opening it in Internet Explorer,... (4 Replies)
Discussion started by: los111
4 Replies

5. Shell Programming and Scripting

Flat file

Hi I have a flat file looking this QWER 2:35 7044 00001 ROUT 1188 EA SS ASD 2:36 7044 00010 ROUT BSD 2:37 7044 00011 ROUT END QWER 3:35 7044 00011 ROUT 1088 EA SS ASD 3:36 7044 00010 ROUT BSD 3:37 7044 00011 ROUT... (9 Replies)
Discussion started by: Krishnaramjis
9 Replies

6. Shell Programming and Scripting

Flat File in HP-UX

Hi I have a file like below . IF the record starts with ASD then change the 20th offset to "K" follwed by that 20th offset value & if the record starts with ASDR then change the 38th offset to "K" followed by 38th offset value . But here the condition is the next value ... (0 Replies)
Discussion started by: Krishnaramjis
0 Replies

7. Programming

compare XML/flat file with UNIX file system structure

Before i start doing something, I wanted to know whether the approach to compare XML file with UNIX file system structure. I have a pre-configured file(contains a list of paths to executables) and i need to check against the UNIX directory structure. what are the various approches should i use ? I... (6 Replies)
Discussion started by: shafi2all
6 Replies

8. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

9. Shell Programming and Scripting

Removing all except couple of html tags from html file

I tried to find elegant (or at least simple) way to remove all but couple of html tags from html file, but all examples I found dealt with removing all the tags. The logic of the script would be: - if there is <li> or <ul> on the line, do nothing (=write same line to output) - if there is:... (0 Replies)
Discussion started by: juubuntu
0 Replies

10. Shell Programming and Scripting

reading a csv file and creating a flat file

hi i have written a script for reading a csv file and creating a flat file, suggest if this script can be optimized #---------------- FILENAME="$1" SCRIPT=$(basename $0) #-----------------------------------------// function usage { echo "\nUSAGE: $THIS_SCRIPT file_to_process\n"... (3 Replies)
Discussion started by: mprakasheee
3 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 03:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy