join scrambles output

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












For some reason my output of join is strange and scrambled; here is the command I use:



join -t, -j 1 -o1.1,2.2,1.2 f1 f2


Where f1:



1,87


and f2:



1,337


The output is:



,8737


and I am at loss as to why the output of join is not as expected. I have checked my locale already, with no luck.



Any ideas?







share|improve this question

















  • 2




    Does the file have DOS line endings (CR LF)? Add the output of join -t, -j 1 -o1.1,2.2,1.2 f1 f2 | od -c please.
    – muru
    Jul 5 at 6:15










  • Thanks, I did not know the od command ! Your intuition was right, it is DOS endings
    – Tiphaine
    Jul 5 at 6:24














up vote
0
down vote

favorite












For some reason my output of join is strange and scrambled; here is the command I use:



join -t, -j 1 -o1.1,2.2,1.2 f1 f2


Where f1:



1,87


and f2:



1,337


The output is:



,8737


and I am at loss as to why the output of join is not as expected. I have checked my locale already, with no luck.



Any ideas?







share|improve this question

















  • 2




    Does the file have DOS line endings (CR LF)? Add the output of join -t, -j 1 -o1.1,2.2,1.2 f1 f2 | od -c please.
    – muru
    Jul 5 at 6:15










  • Thanks, I did not know the od command ! Your intuition was right, it is DOS endings
    – Tiphaine
    Jul 5 at 6:24












up vote
0
down vote

favorite









up vote
0
down vote

favorite











For some reason my output of join is strange and scrambled; here is the command I use:



join -t, -j 1 -o1.1,2.2,1.2 f1 f2


Where f1:



1,87


and f2:



1,337


The output is:



,8737


and I am at loss as to why the output of join is not as expected. I have checked my locale already, with no luck.



Any ideas?







share|improve this question













For some reason my output of join is strange and scrambled; here is the command I use:



join -t, -j 1 -o1.1,2.2,1.2 f1 f2


Where f1:



1,87


and f2:



1,337


The output is:



,8737


and I am at loss as to why the output of join is not as expected. I have checked my locale already, with no luck.



Any ideas?









share|improve this question












share|improve this question




share|improve this question








edited Jul 5 at 6:14









muru

33.1k576139




33.1k576139









asked Jul 5 at 6:12









Tiphaine

31




31







  • 2




    Does the file have DOS line endings (CR LF)? Add the output of join -t, -j 1 -o1.1,2.2,1.2 f1 f2 | od -c please.
    – muru
    Jul 5 at 6:15










  • Thanks, I did not know the od command ! Your intuition was right, it is DOS endings
    – Tiphaine
    Jul 5 at 6:24












  • 2




    Does the file have DOS line endings (CR LF)? Add the output of join -t, -j 1 -o1.1,2.2,1.2 f1 f2 | od -c please.
    – muru
    Jul 5 at 6:15










  • Thanks, I did not know the od command ! Your intuition was right, it is DOS endings
    – Tiphaine
    Jul 5 at 6:24







2




2




Does the file have DOS line endings (CR LF)? Add the output of join -t, -j 1 -o1.1,2.2,1.2 f1 f2 | od -c please.
– muru
Jul 5 at 6:15




Does the file have DOS line endings (CR LF)? Add the output of join -t, -j 1 -o1.1,2.2,1.2 f1 f2 | od -c please.
– muru
Jul 5 at 6:15












Thanks, I did not know the od command ! Your intuition was right, it is DOS endings
– Tiphaine
Jul 5 at 6:24




Thanks, I did not know the od command ! Your intuition was right, it is DOS endings
– Tiphaine
Jul 5 at 6:24










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Your data file are DOS text files. Each line has a trailing carriage return character.



The output that you expect is



1,337,87


but since there is a carriage return after the 7 in 337 (from the DOS line-ending in the second file), the cursor moves back to the start of the line before printing ,87, overwriting 1,33 there.



Run dos2unix on the data files to convert them to Unix text files, or instruct whatever program that creates them to create Unix text files.






share|improve this answer





















  • Thanks, indeed this is it. I suspected it at first but threw that idea of since the files were made by a colleague on MacOS, it it seems the python csv module output DOS files by default
    – Tiphaine
    Jul 5 at 6:25










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453535%2fjoin-scrambles-output%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










Your data file are DOS text files. Each line has a trailing carriage return character.



The output that you expect is



1,337,87


but since there is a carriage return after the 7 in 337 (from the DOS line-ending in the second file), the cursor moves back to the start of the line before printing ,87, overwriting 1,33 there.



Run dos2unix on the data files to convert them to Unix text files, or instruct whatever program that creates them to create Unix text files.






share|improve this answer





















  • Thanks, indeed this is it. I suspected it at first but threw that idea of since the files were made by a colleague on MacOS, it it seems the python csv module output DOS files by default
    – Tiphaine
    Jul 5 at 6:25














up vote
2
down vote



accepted










Your data file are DOS text files. Each line has a trailing carriage return character.



The output that you expect is



1,337,87


but since there is a carriage return after the 7 in 337 (from the DOS line-ending in the second file), the cursor moves back to the start of the line before printing ,87, overwriting 1,33 there.



Run dos2unix on the data files to convert them to Unix text files, or instruct whatever program that creates them to create Unix text files.






share|improve this answer





















  • Thanks, indeed this is it. I suspected it at first but threw that idea of since the files were made by a colleague on MacOS, it it seems the python csv module output DOS files by default
    – Tiphaine
    Jul 5 at 6:25












up vote
2
down vote



accepted







up vote
2
down vote



accepted






Your data file are DOS text files. Each line has a trailing carriage return character.



The output that you expect is



1,337,87


but since there is a carriage return after the 7 in 337 (from the DOS line-ending in the second file), the cursor moves back to the start of the line before printing ,87, overwriting 1,33 there.



Run dos2unix on the data files to convert them to Unix text files, or instruct whatever program that creates them to create Unix text files.






share|improve this answer













Your data file are DOS text files. Each line has a trailing carriage return character.



The output that you expect is



1,337,87


but since there is a carriage return after the 7 in 337 (from the DOS line-ending in the second file), the cursor moves back to the start of the line before printing ,87, overwriting 1,33 there.



Run dos2unix on the data files to convert them to Unix text files, or instruct whatever program that creates them to create Unix text files.







share|improve this answer













share|improve this answer



share|improve this answer











answered Jul 5 at 6:17









Kusalananda

101k13199312




101k13199312











  • Thanks, indeed this is it. I suspected it at first but threw that idea of since the files were made by a colleague on MacOS, it it seems the python csv module output DOS files by default
    – Tiphaine
    Jul 5 at 6:25
















  • Thanks, indeed this is it. I suspected it at first but threw that idea of since the files were made by a colleague on MacOS, it it seems the python csv module output DOS files by default
    – Tiphaine
    Jul 5 at 6:25















Thanks, indeed this is it. I suspected it at first but threw that idea of since the files were made by a colleague on MacOS, it it seems the python csv module output DOS files by default
– Tiphaine
Jul 5 at 6:25




Thanks, indeed this is it. I suspected it at first but threw that idea of since the files were made by a colleague on MacOS, it it seems the python csv module output DOS files by default
– Tiphaine
Jul 5 at 6:25












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453535%2fjoin-scrambles-output%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay