Sponsored Content
Top Forums Shell Programming and Scripting Insert text line to specific location CSV Post 302733031 by in2nix4life on Monday 19th of November 2012 02:58:59 PM
Old 11-19-2012
Code:
#!/usr/bin/perl
#

use strict;
use diagnostics;

my @data;
my @sorted_data;
my $csvfile = "details.csv";

open(FH, "<$csvfile") or die "Unable to open $csvfile.\n";
@data = <FH>;
@sorted_data = sort { (split ',', $a)[0] <=> (split ',', $b)[0] } @data;
foreach(@sorted_data) { print; }
close(FH);
exit(0);

This User Gave Thanks to in2nix4life For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert lines at specific location in file

Hi There I have this file that I would like to add entries to, however, there is a "}" as the last line that I need to keep. Basically i would like to know how I can write a script that will add new lines at the second to last line position (ie always add new line above the close bracket) ... (17 Replies)
Discussion started by: hcclnoodles
17 Replies

2. HP-UX

replacing text in specific location

i have a file that looks like this: 000000112/01/2008 D99999 000000 12/01/2008 D99999 000000 12/01/2008 1D99999 i need to replace the blanks into 1 for column 7,18-19 how can this be achieved using awk? Thanks. (1 Reply)
Discussion started by: zeontman
1 Replies

3. Shell Programming and Scripting

Insert 2 lines in a file at a specific location

Hi, I need to insert two new lines in a file: The file: "..... ...... ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`" .... .... " I need to add the lines: LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$APACHE_HOME/modules' DOWNLOADMODULE_CONF_PATHNAME='$APACHE_HOME/conf/DWLModule.cfg' right... (2 Replies)
Discussion started by: potro
2 Replies

4. Shell Programming and Scripting

Insert a text from a specific row into a specific column using SED or AWK

Hi, I am having trouble converting a text file. I have been working for this whole day now, still i couldn't make it. Here is how the text file looks: _______________________________________________________ DEVICE STATUS INFORMATION FOR LOCATION 1: OPER STATES: Disabled E:Enabled ... (5 Replies)
Discussion started by: Issemael
5 Replies

5. Shell Programming and Scripting

How to append a string to a specific location in a line

Hi, I have a to modify a line and insert a keyword in the middle to a specific location. My line looks like this FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS (ABC, DEF, GHI) I want to change it as FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING... (4 Replies)
Discussion started by: mwrg
4 Replies

6. Shell Programming and Scripting

Copying x words from end of line to specific location in same line

Hello all i know it is pretty hard one but you will manage it all after noticing and calculating i find a rhythm for the file i want to edit to copy the last 12 characters in line but the problem is to add after first 25 characters in same line in other way too copy the last 12 characters... (10 Replies)
Discussion started by: princesasa
10 Replies

7. Shell Programming and Scripting

insert data into specific lines of a CSV

So I work in a 1 to 1 laptop deployment and sometimes we need to mass order parts. The vendor will send us a text file and we have to manually input serial numbers. Well I have a full blown web based inventory system which I can pull serial number reports from. I then have to input the part... (4 Replies)
Discussion started by: tlarkin
4 Replies

8. UNIX for Advanced & Expert Users

unix command : how to insert text at the cursor location via command line?

Hi, Well my title isn't very clear I think. So to understand my goal: I have a script "test1" #!/bin/bash xvkbd -text blabla with xbindkeys, I bind F5 key in order it runs my test1 script So when I press F5, test1 runs. I'm under Emacs/Vi and I press F5 in order to have "blabla" be... (0 Replies)
Discussion started by: xib.be
0 Replies

9. Shell Programming and Scripting

Interchange location of words in a line of csv file

Hi, I have a file with some info as example below. Its a csv file and i want to interchange the location of the times and dates in the 3rd and 4th fields only. I am using SunOS and csh script and would like to incorporate sed or nawk in the script (or any that would be able to accomplish this).... (5 Replies)
Discussion started by: viper1503
5 Replies

10. Shell Programming and Scripting

Insert character at specific location in a each line of the file

Hi All, I am trying to write a shell script where it should insert character 'I' in 180th position of each line(except first and last line) of the file. Below is the script for file in /home/test/bharat/*.RET do # Process file echo "File Name=" $file #l_fileName="${file##*/}" ... (19 Replies)
Discussion started by: bharath561989
19 Replies
OWX(1)							      General Commands Manual							    OWX(1)

NAME
owx - utility to program Wouxun dual-band handheld radios SYNOPSIS
owx-check [ -v | -h ] [ -f ] [ -p <port> ] [ -t <timeout> ] owx-get [ -v | -h ] [ -f ] [ -p <port> ] [ -t <timeout> ] -o <path> owx-put [ -v | -h ] [ -f ] [ -p <port> ] [ -t <timeout> ] -i <path> -r <path> owx-export [ -v | -h ] -i <bin path> -o <csv path> owx-import [ -v | -h ] -i <csv path> -o <bin path> DESCRIPTION
This manual page documents briefly the owx commands. owx is a set of commands that will allow you to fetch and update configuration on your Wouxun handheld radio. It is made of multiple com- mands. COMMON OPTIONS
These options are common to all commands. -h Show summary of options. -v Show version of program. -c <command> Invoke owx-<command>. Makes sense only if called directly as owx. OPTIONS FOR check, get AND put -f Force operation even if your radio identifies different from a KG669V. Use this option with extreme caution - it is very possible that your radio will be rendered unusable after you use this. It was NEVER tested with any radio different from mentoined above. -p <port> Use port <port>, defaults to /dev/ttyUSB0. Of course you must have appropriate read and write permissions for this device. -t <timeout> Specify the receive timeout for communication with radio. If you disable it (by setting to 0) and the communication fails, the pro- gram will hang forever. You probably don't need to change the default value (5 seconds). USAGE
owx-check This program just checks for the connection and identification string. It can be used to check that your cable and port works. owx-get This program downloads memory map from radio to binary file. Options: -o <path>: binary file to write to owx-put This program uploads memory map from binary file to radio. Options: -i <path>: binary file to read from -r <path>: reference file Option -r is not mandatory, but recommended. You can specify original, unchanged file (exactly as downloaded using owx-get) and this will speed up memory uploading, as owx will compare input file to this reference file and upload only changed memory pages. When using this option, be sure that nothing has changed in the radio (even the currently selected memory channel) between downloading reference file and using it for upload. This is important as some variables that cross the page boundaries (if there are any in the memory map) could be corrupted by this. Example: owx-get -o file.bin cp file.bin backup.bin owx-export -i file.bin -o wouxun.csv oocalc wouxun.csv owx-import -i wouxun.csv -o file.bin owx-put -i file.bin -r backup.bin Please do yourself a favour and double-check that you upload the correct file. If you try to upload incorrect or corrupted file, your radio will power down and fail to power up. owx will refuse to upload any file with incorrect size, but this is the only safety check. owx-export This program exports channel data from binary file to CSV file. This file can be later edited using your favourite spreadsheet edi- tor or even text editor. Options: -i <path>: binary file to read from -o <path>: csv file to write to owx-import This program reads the specified, possibly edited by you CSV file, and patches existing binary file with this updated data. The file is now prepared to be uploaded with owx-put. Options: -i <path>: csv file to read from -o <path>: binary file to write to (must already exist) SEE ALSO
chirp(1), the README file. AUTHOR
owx was written by SP5GOF (Adam Wysocki). This manual page was written by Antoine Beaupre <anarcat@debian.org>, for the Debian project (and may be used by others). October 26, 2011 OWX(1)
All times are GMT -4. The time now is 10:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy