Tag Archives: TXT

Extract column data

By newkid.7955

I have a file which extracts data from an HTML file
For Eg HTML file contains:

Code:

New York;ABC;145;Yes;YES;No
New York;BCD;113;Yes;YES;No
New York;NAS;63;Yes;YES;No
------------------------
London-48;CBT;16;Yes;YES;No
London-48;CME;17;Yes;YES;No
London-48;EUR;52;Yes;YES;No
London-48;EUR;188;Yes;YES;No
London-48;USx;66;Yes;YES;No
London-48;AMS;172
178;Yes
Yes;YES
YES;no
no
London-48;LIFE;172
174
178;Yes
Yes
Yes;YES
YES
YES;no
no
no
London-48;EUEd;175;Yes;YES;no
London-48;FOXN;177;Yes;YES;no
London-48;BIRD;177;Yes;YES;no
London-48;MOND;177;Yes;YES;no
London-48;EUI;174;Yes;YES;no
London-48;XEC;15;Yes;No;No
London-48;BRUS;95;Yes;No;No
London-48;NYMC;15;Yes;No;No
-----------------------------
London-47;WBOx;28;Yes;YES;No
London-47;BCD;20;Yes;No;No
London-47;MCe;89;Yes;YES;No
London-47;DUBL;87;Yes;YES;No
London-47;CIHX;34;Yes;YES;No
London-47;Ctaf;203;Yes;No;No
London-47;LUXA;95;Yes;YES;No
London-47;LUXB;95;Yes;YES;No
London-47;LUXP;95;Yes;YES;No
London-47;NEBX;95;Yes;YES;No
London-47;NXEL;95;Yes;YES;No
London-47;misc;95;Yes;YES;No
London-47;BXNJ;95;Yes;YES;No
London-47;LANT;95;Yes;YES;No
London-47;LANB;95;Yes;YES;No
London-47;MASD;95;Yes;YES;No
London-47;BRUS;95;Yes;YES;No
London-47;LISB;95;Yes;YES;No
London-47;LIST;95;Yes;YES;No
London-47;PARF;95;Yes;YES;No
London-47;JSEB;31;Yes;YES;No
London-47;LoND;33;Yes;YES;No


As a TXT file, it gets:

It is in the format of

Code:

Server;Country;Num;Data1;Data2;Data3


If there are multiple Num column, then it is in the format

Code:

Server;Country;
Num1
Num2;Data1ofNum1
Data1ofNum2;Data2ofNum1
Data2ofNum2;Data3ofNum1
Data3ofNum2


Now I need to write a uniq script where the user needs to find a server which has routing and Data2 lets say:

FOR EG of entered data: BRUS Data2

I want to see if data 2 + BRUS is available on a server, it should return London-47, London-48

but the problem is that the txt file grabs data per column and not by row.

If this question is not so clear please inform me.

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Renaming the file name for n number of files

By chillblue

Hi ,

I am kind of new to shell scripting and found a situation to handle …

I have few files which will be ftpd in to our sustem , the file names needs to be renamed based on condition.

————

HTML Code:

Eg file names :-

AE_JUNFOR_2013_MTD_2013-04-09-08-30-09.TXT
AE_JUNFOR_2013_YTD_2013-04-09-08-30-09.TXT
temp_AE_JUNFOR_2013_MTD_2013-04-09-08-30-09.TXT
AE_JUNFOR_2014_MTD_2013-04-09-08-30-09.TXT
AE_JUNFOR_2014_YTD_2013-04-09-08-30-09.TXT
temp_AE_JUNFOR_2014_MTD_2013-04-09-08-30-09.TXT


The files needs to be renamed if the file name contains “JUNFOR” and “2013” in then.

The rename should happen only for JUNFOR and 2013 combinations.

HTML Code:

Resulting File names :-

AE_FOR13_2013_MTD_2013-04-09-08-30-09.TXT
AE_FOR13_2013_YTD_2013-04-09-08-30-09.TXT
temp_AE_FOR13_2013_MTD_2013-04-09-08-30-09.TXT
AE_JUNFOR_2014_MTD_2013-04-09-08-30-09.TXT
AE_JUNFOR_2014_YTD_2013-04-09-08-30-09.TXT
temp_AE_JUNFOR_2014_MTD_2013-04-09-08-30-09.TXT


The folder can contain any number of files in it .. The first three files for one set and the second and so forth.

Please let me know how to handle this renaming.

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Should You Buy Textron Near Its 52-Week-high?

By Steve Symington, The Motley Fool

TXT Chart

Filed under:

Textron has always been an intriguing beast to me.

After all, in 2006 the aerospace conglomerate acquired the comparatively small software outfit by which I was hired straight out of college, effectively taking us under its massive wings.

Consequently, thanks to an impending financial meltdown and Textron’s own overexposure to its struggling financial segment, I learned some fantastic lessons about keeping too much of our own company’s stock in my 401(k) plan during that time.

TXT data by YCharts

Luckily, my retirement accounts were still relatively young (read “small”), so the lesson couldn’t have come at a better time. 

The products
Still, that gave me plenty of excuses to dig into my new parent company’s operations, helping me learn of its incredible global reach thanks to its ownership of Cessna, Bell Helicopter, and unmanned aircraft specialist AAI. In addition, Textron builds golf carts through its E-Z-GO subsidiary, commercial lawn mowers through Jacobsen, and hand tools through Greenlee. What’s more, thanks to its ownership of Kautex, we can add to the list automotive parts like gas tanks, windshield washer systems, camshafts, and catalytic converters.

But what really caught my attention were some of Textron’s other military-centric products, including it’s armored security vehicles (known for their IED-deflecting “V” shaped hulls), RPG protection systems, a self-righting 47-foot rescue boat, and a giant, widely used hovercraft capable of carrying a 75-ton payload at speeds of over 40 knots — for all you non-seafolk, that’s a ridiculous amount of weight to push at 46 miles per hour!

We also can’t forget Textron’s “Lightweight Tactical Small Arms” tech, which promises to reduce the weight of traditional carbine rifles and ammo by 50%, thanks largely to the use of high-tech caseless ammunition. If that’s still not enough, you might take a peek at its Sensor Fuzed Weapon — a “smart” cluster bomb capable of selectively destroying dozens of targets via munitions which contain built-in logic to either self-destruct in the air or render themselves inert within minutes of hitting the ground if they don’t find a suitable target. The result? A clean battlefield with zero civilian casualties to date, and a few pretty amusing first-hand accounts of the weapon’s effectiveness. 

The numbers
To be fair, however, the best product portfolio in the world isn’t worth much if the company can’t turn a profit. Luckily for Textron shareholders, after struggling mightily through the end of 2010, the company has managed to post respectable profits in seven of its eight most recent quarters, with the sole outlier being its fourth quarter of 2011, during which the company metaphorically ripped off its bandages and took $0.55 per share in charges. Fortunately, the bulk of those charges were the result of mark-to-market adjustments related to the winding down of its troublesome finance segment.

Meanwhile, Bell Helicopter continues to fire on all cylinders as the company sold 24 of its H-1 helicopters …read more
Source: FULL ARTICLE at DailyFinance

Fix script error (%%n)

By pasc

Hi,

I’m currently tinkering with a script that uses the for command to process all *.gif files in the current folder.

I marked the spot where it exits out with an error by adding a “pause”

The error message given is:

Code:

convert.exe: unable to open image `%x': No such file or directory @ error/blob.c
/OpenBlob/2641.
convert.exe: no decode delegate for this image format `%x' @ error/constitute.c/
ReadImage/550.
convert.exe: invalid argument for option `-geometry': ) @ error/convert.c/Conver
tImageCommand/1619.


The script is:

Code:

@echo off

SET REP="C:UsersPascalDesktopMMBN3ProgramsProgramParts1blnk.gif"
SET SUB="C:UsersPascalDesktopMMBN3ProgramsProgramParts2blnkCMD.gif"
SET SRC=%%n
:start

for %%n in (*.gif) do (
"%IMG%compare" -metric RMSE %%n %SUB% -subimage-search found.png 2>co.txt
)
set /p xycos= <co.txt
set str=%xycos%
echo.%str%
set str=%str:,=+%
ECHO %str% > co.TXT
set /p xycos= <co.txt
set str=%xycos%
echo."%str%"
set str=%str: =%
ECHO %str% > co.TXT
set /p xycos= <co.txt
set str=%xycos%
echo.%str%
set str=%str:@= +%
ECHO %str% > co.TXT
set /p xycos= <co.txt
set str=%xycos%
echo.%str%
set str=%str:~-12%
ECHO %str% > co.TXT
set /p xcoyco= <co.txt
ECHO %str% >> coordinates.TXT
pause
for %%n in (*.gif) do CALL :run
:run
"%IMG%convert" ^
%%x ^
( %REP% -geometry %xcoyco% ) ^
-composite ^
%%x
ECHO %str% >> coordinates.TXT
goto start


Thanks in advance for your help

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Date format to be changed from DDMMYYYY to YYYYMMDD

By djrulz123

My requirement is:- there will be files at a location each day with the date format DDMMYYYY.

Novawise_Activity_Call_Notes_04022013.txt
Novawise_Activity_Inbound_04022013.txt
Novawise_Activity_Inbound_05022013.txt
Novawise_Activity_Call_Notes_05022013.txt
Novawise_Activity_Call_Notes_06022013.txt
Novawise_Activity_Inbound_06022013.txt

Now in another file we store the last run date (LAST_DATE.TXT) in the format 20130405(YYYYMMDD). The current value is 20130405.

I want to pick up only the files for the 6th and not the 4th and the 5th. And then store the date 06022013 (from the file) into the LAST_DATE.TXT file in the format 20130406.
Hence i would process each day only those files which are latest and after the last run date.

Please let me know how this can be done.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Repeat part of script infinitely ?

By pasc

I currently have this script:


"%IMG%compare" -metric RMSE %SRC% %SUB% -subimage-search found.png 2>co.txt
set /p xycos= <co.txt
set str=%xycos%
echo.%str%
set str=%str:,=+%
ECHO %str% > co.TXT
set /p xycos= <co.txt
set str=%xycos%
echo."%str%"
set str=%str: =%
ECHO %str% > co.TXT
set /p xycos= <co.txt
set str=%xycos%
echo.%str%
set str=%str:@= +%
ECHO %str% > co.TXT
set /p xycos= <co.txt
set str=%xycos%
echo.%str%
set str=%str:~-8%
ECHO %str% > co.TXT
set /p xcoyco= <co.txt
"%IMG%convert" ^
%SRC% ^
( %REP% -geometry %xcoyco% ) ^
-composite ^
%SOURCE%
DEL found-0.png
DEL found-1.png


Is there any way I can repeat it infinitely till it terminates itself (will happen once it won’t find any more matches) ?

I haven’t found such method in DOS yet and pasting the script a dozen hundered time isn’t what I’m after either.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Looking for a file within a given slackware distribution.

By stf92

Hi: suppose you want to look for file foo belonging to the Slackware N.N distribution. Then either you make a full installation or N.N and look into /var/log/packages (grep) or you go to some Slackware index tree in the web and you traverse the tree node by node, which would be a great deal of work to do and therefor impracticable.

Now suppose further that you are not able, momentarily, to install N.N to your disk. Perhaps you have it now occupied by another O.S. or for whatever reason. So your only place where to look at is the N.N disk itself. In this disk your have PACKAGES.TXT and FILELIST.TXT. But neither of these will do. They list packages but not their contents.

So, in spite of having the disk, you arent able to know if foo is there or not or, in case you know it is, in which package. Is this really true?

Source: FULL ARTICLE at The UNIX and Linux Forums

Can Anyone help me..to do my task in simple way..

By nex_asp

Hi…

I am trying extract data using 2 files..

1. Data file – DATA.TXT containing data to be extracted
2. Column file – LIST.TXT header column to be extracted

output not coming properly..

if the header field name matches with data file header extract data…this actually I wanted …

Code:

#!/bin/bash

DATAFILE=${1:-DATA.TXT}
COLUMNFILE=${2:-LIST.TXT}

awk -F, -v colsFile="$COLUMNFILE" '
BEGIN {
j=1
while ((getline 0) {
col[j++] = $1
}
n=j-1;
close(colsFile)
for (i=1; i<=n; i++) s[col[i]]=i
}
NR==1 {
for (f=1; f<=NF; f++)
if ($f in s) c[s[$f]]=f
next
}
{ sep=""
for (f=1; f<=n; f++) {
printf("%c%s",sep,$c[f])
sep=FS
}
print ""
}
' "$DATAFILE"


Code:

cat DATA.TXT
ID, head1, head2, head3, head4
1, 25.5, 1364.0, 22.5, 13.2
2, 10.1, 215.56, 1.15, 22.2

cat LIST.TXT
ID
head1
head4

sh extract.sh DATA.TXT LIST.TXT
1,1, 25.5, 1364.0, 22.5, 13.2,1, 25.5, 1364.0, 22.5, 13.2
2,2, 10.1, 215.56, 1.15, 22.2,2, 10.1, 215.56, 1.15, 22.2


and I want to display it as space separated ..

Code:

awk '{print $3,$2,$1}' FS="," DATA.TXT
whether here some changes can be done to get desired output


please help..

Attached Files
File Type: txt LIST.TXT (15 Bytes)
File Type: txt DATA.TXT (87 Bytes)

Source: FULL ARTICLE at The UNIX and Linux Forums

Replace semicolons with tabulators, new lines are disappearing

By JanneN

Hi Gurus!
Example file:
1;AAA;BBB
2;CCC;DDD

We want to replace semicolons to tabulators.
Like this:
1 AAA BBB
2 CCC DDD

We have tried these codes.
With PERL:

Code:

#!/bin/bash
for i in `find /folder1/ -name "*.CSV"`

do
bi="`basename $i awk -F"." {'print $1'}`"

cat $bi.CSV perl -p -e 's/;/t/g' > /folder1/$bi.TXT

mv $bi.CSV /folder2/

done


and same with SED:

Code:

#!/bin/bash
for i in `find /folder1/ -name "*.CSV"`

do
bi="`basename $i awk -F"." {'print $1'}`"

sed 's/;/t/g' $i > /folder1/$bi.TXT

mv $bi.CSV /folder2/

done


But when processed, all the rows are concatenated to one row, like this:
1 AAA BBB 2 CCC DDD

What can be wrong with the script?

Source: FULL ARTICLE at The UNIX and Linux Forums