Programming :: Command "join" Missing Some Rows?
Apr 30, 2011
Am a bit bewildered on the output of this "join" comad. I'm expecting it to output the 2nd and 3rd columns of both text1.txt and text2.txt. However, it somehow misses some of the columns from text1.txt. For example, rows 1, 2, 8, and 14 are working as expected. The rest of the row aren't.
Code:
cat text1.txt
20110429,10480,Y
20110429,5202,Y
20110429,19434,Y
20110429,19417,Y
[code]....
View 3 Replies
ADVERTISEMENT
Mar 2, 2011
I am trying to understand the join command. I wish to join two files:
Code:
$ cat test1
a 0
b 2.51
c 19.85
$ cat test2
a 0
b 2.51
[Code]...
this is great but I do not understand why join ignores the -e flag and fails to insert FOO in the empty field.
View 1 Replies
View Related
Jul 20, 2010
I have a big file full of records like this
1, 2, 4, 5, 6
1, 3, 5, 6, 3
1, 4, 5, 6, 6
2, 4, 5, 5, 5
2, 3, 4, 5, 2
anyway i need to take the average of all rows with the same 1st number(key). i.e.
1, 3, 4.66, 5.66, 5
2, 3.5, 4.5, 5, 3.5
I know this is something awk/sed would be great for, i just dont have enough experience with them to accomplish it, Also, what about averaging those columns together? so, after I output this to a file, id like to get another like:
1, 4.58
1, 4.125
The number of colums to add might not always be 4 either. EDIT: this might be easier to do in gnuplot, so I mainly just need an answer to the first part.
View 3 Replies
View Related
Aug 10, 2009
I bet this is a Perl one-liner (or very simple python script).I have a tab separated files in which each row looks like:Unique_Eight_Character_Sequence [3 tabs] data1~moredata1~moredata1 [3 tabs] data2~ moredata2~ moredata2 ... dataN~.The output file should have each column converted into a row (with the unique character sequence copied in for the first column), and then each "~" replaced by a comma.
View 14 Replies
View Related
Aug 21, 2010
I would like to compare to mysql rows as follows:
Select count(*) from stocks2.historical where close*1.05 < (select open from stocks2.historical where date = date_add(date,interval 1 day))
and year(date)=2010;
The problem is with the "date" in bold... i want that date to be the date of the previous row. is there a way to do that purely with mysql? (naturally, i can write a script to go through and compare each date; what i'm asking for is a mysql solution.)
View 3 Replies
View Related
Oct 27, 2010
In placing array data into while statement that will be looped to recreate more lines as information is populated.
unfortunately i'm not getting this to work.
PHP Code:
View 2 Replies
View Related
Apr 6, 2010
How can I delete selected rows of a table in perl/CGI??
View 5 Replies
View Related
Aug 16, 2010
I have a problem - I have files with rows of data and I need to check if the next row (of the same type) has the NEXT date in it so I need to extract a date in YYYYMMDD format from a row (easy enough) then add one day to it and compare it to the the next date I encounter on a subsequent row.
So if I have
DATE|20100530
VAL|kahskjhd
[code]...
View 6 Replies
View Related
May 26, 2011
I've been hitting my head against a wall for awhile with this one:As the last part of some data analysis I performing I would to construct a matrix from a series of different files. These files have the format:
file 1 file 2 file 3
AAAAA .1 AAAAA .1 BBBBB .1
BBBBB .2 BBBBB .1 CCCCC .9
[code]...
View 6 Replies
View Related
Jun 21, 2010
How can I delete rows into text file in perl?
View 4 Replies
View Related
Jul 18, 2011
In linux terminal; how can we get the number of rows ad columns from linux kernel? I tried from environment variables(LINES,COLUMNS) but, I could not retrieve them as my editor program is a child process to linux terminal process.
View 7 Replies
View Related
Feb 10, 2011
Going through book, "Guide to UNIX Using Linux". I am doing one of the projects that has me writing scripts to join files. Here is my pnumname script and I am extracting the programmers names and numbers from the program file and redirecting the output to the file pnn. I then created a joinall script where I am trying to join the files pnn and pnumname and redirect the output to pactrep. When I run the script sh joinall and use less to display the contents of the redirected file pactrep, I get an error- join: extra operand `pnum'
Try `join --help' for more information.... I went to the man pages but I still (obvious) do not have a solid grasp.
#=======================================================
# Script Name: pnumname
# By: J.D.
[code]....
View 1 Replies
View Related
May 4, 2010
with my question (I�m using Cygwin). How can I join the 2 AWK scripts showed below in a unique script avoiding use temp file?
I have this input file Pipe separated. Code: CATEGORY1|CATEGORY2|CATEGORY3|CATEGORY4
String3|MUSIC/OLDIES/POP/80S/SONGW|String4|
String4|MUSIC/OLDIES/ROCK/70S/SONGX|String5|
[code]....
View 1 Replies
View Related
Jul 1, 2010
I have a large CSV file, tab-delimited with CRLF at the end of each line. Each line should contain 5 fields (i.e. NF == 5) However, there are rogue CRLF characters in the middle of some records, causing records to be split across two lines. I want to scan each line, check the field count and if it's !=5 then join that line to the following line. Example input might be;
Code:
one two three four five
six seven eight nine ten
eleven tw<CRLF>
elve thirteen fourteen fifteen
[code].....
View 2 Replies
View Related
Aug 19, 2010
I have a bunch of files that contain a date, then data. When I use join, I get exactly the output I need. But manually joining the first with the second, then that output with the third and so on would take days. I have thousands of files. Can any of you folks help me write a script that would do this?To put it another way, for clarity's sake, here is what I am currently doing
If I were to repeat that 3000 times the final output would be what I need. I know a simple script would do this for me, but I can't figure out how to write it.
View 12 Replies
View Related
Nov 26, 2010
I have been searching previous posts but could not find an example which works with my data. I think I might be the spaces in my fields. I have a massive data file and need to join 5 line blocks separated by a comma.
Code:
2
111.222.333.444
host.edu
[code].....
View 8 Replies
View Related
Jun 18, 2010
Code: cmd='date | wc'
$cmd If this script is executed, an error is generated. The reason written was that "The execution fails because the pipe is not expanded and is passed to date as an argument".What is meant by expansion of pipe. When we execute date | wc on the command line, it goes fine.then | is not treated as an argument. Why?
View 4 Replies
View Related
Feb 16, 2010
I am trying to learn how to pass more than a one-command startup for gnome-terminal.
I will give an example of what I'm trying to do here:
Code:
#! /bin/bash
#
#TODO write this for gnome and xterm
USAGE="
${0##*/} [-x] [-g]
code....
However, running with the -g option to invoke gnome-terminal, I get a "There was an error creating the child process for this terminal" error.
This same error occurs if the gnome-terminal line is changed to
Code:
gnome-terminal -e mcTerm
Is there any way to pass more than one command on to gnome-terminal? I have tried various single and double quoting senarios and in a final attempt, I abstracted to an exported function all to no avail. Perhaps even though gnome-term is better at many things than xterm, xterm trumps it in this instance.
View 4 Replies
View Related
Apr 13, 2010
I am writing a perl script which uses the matlab compiler to compile a .m file.
I am using the system("mcc �m file.m"). I have matlab installed and both script and exe are in the same drive.But i get the following error .
'mcc' is not a recognised as an internal or external command ,operable in program or batch file.
View 5 Replies
View Related
Oct 20, 2010
I am using gtk to program GUI. How can I show the output of shell command into a textbox, ex ps -efc command ?
View 3 Replies
View Related
Oct 15, 2010
I'm trying to convert this awk command from command line into an awk script, but just cannot get it to work:
This is what i have after my BEGIN
Am i missing something here? this just prints out the count for everyline, not counting lines on 5th field that match 'A'
View 1 Replies
View Related
Nov 19, 2008
suppose i store the history number of a command say :
1004 cat file
Then now i want to run it like : !1004 but by using a variable.
command=1004
!$command
i am getting errors like :
command=1004command
View 2 Replies
View Related
Aug 27, 2010
I have been messing with a2ps in order to print a text file I have that has 130 columns by 80 rows per page. It appears that a2ps automatically scales the number of rows based upon the number of columns I try to print.The file prints properly for the columns but a2ps scales the rows to be 97 rows per page. So the 80 rows print but the next 17 rows are blank. It is not scaling the font for for 80 rows.
View 1 Replies
View Related
Jul 15, 2010
Something unfortunate just happened. I was editing the bash file from my terminal and changed a source. After this I was no longer able to input commands for interpreting in the terminal.
View 13 Replies
View Related
Jan 25, 2011
I am trying to do a string search using this a a guide [1] on opensuse 11.xI a missing .rpm containing the string command as when I run the following command # string first a 0a23456789abcdef 5.It returns :If 'string' is not a typo you can use command-not-found to lookup the package that contains it, like this:cnf string
What .rpm do I need to install that has the string command ?
View 1 Replies
View Related
Jun 30, 2010
I've just noticed something odd with 'su'. When you run 'su' with both the '-' (aka -l) and -c command options like this: "su -l user -c command" it doesn't appear to run /etc/profile before running the specified command even though the -l option is specified. If you run "su -l user" without the -c it does run /etc/profile.
Now, on other linux such as fedora it works as expected and runs both /etc/profile followed by the command specified on the '-c'. I'm fairly sure it used to work this way on Slackware (and every other UNIX I've ever used) too. "su -l root -c env" is a good way to see, as you'll find most the environment variables are missing.
View 6 Replies
View Related
Apr 3, 2011
How can i concatenate rows of 2 files.
File1:
File2:
How want file3 to be like?
View 14 Replies
View Related
Jun 14, 2011
When i try to execute scp command:
scp -r /localhostdirectory username@remotehostservername:/remotehostdirectory
I get the following error
0509-036 Cannot load program /usr//bin/ssh because of the following errors:
0509-150 Dependent module /homepath/server/bin/libcrypto.a(libcrypto.so.0.9.8) could not be loaded.
0509-153 File /homepath/server/bin/libcrypto.a is not an archive or
the file could not be read properly.
0509-026 System error: Cannot run a file that does not have a valid format.
View 6 Replies
View Related
Apr 18, 2011
Does anyone have a solution for merging files if the number of rows in the two (or more) files is non-equivalent.To exemplify, how about merging the following 3 files:
file1:
1
2
[code]...
View 8 Replies
View Related
Jul 29, 2011
I would like to transform rows into columns from a file in bash.
View 4 Replies
View Related