hanna
Posts: 19
Joined: Sat Dec 22, 2012 4:25 pm

corrupted text files

Thu Jan 24, 2013 1:13 pm

hey all - i imported a folder full of text (*.txt) documents (recipes, actually) into my Pi for the purposes of accessing them as needed on a shared network. everything looked good on the surface, but now i find that when i actually open each file, it is incomplete or scrambled (most characters are missing, crazy font sizes, scrambled words etc).

not sure what went wrong here - these docs were basically recipes from websites that were copied and pasted into Windows notepad and then saved as text files. once my Pi was in place, I copied the files into the Pi's public folder. would anyone know if this is a Linux problem or a Pi problem or both?

thanks!

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5370
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: corrupted text files

Thu Jan 24, 2013 1:18 pm

If you copy them back to the original PC, can you view them? That will detemine if the files are corrupted, or it's an encoding issue.
What are you using to view them on the Pi?

hanna
Posts: 19
Joined: Sat Dec 22, 2012 4:25 pm

Re: corrupted text files

Thu Jan 24, 2013 1:49 pm

thanks for the reply! just to be clear:
- if i open the file on the Pi itself, it opens with Leafpad and is completely blank.
- if i open the file on the Pi via a Windows machine over the network, it opens with Notepad and is incomplete, missing significant portions of the text.
- if i copy the file from Pi back to a Windows machine, it opens with Notepad and is incomplete.
- i still have the original folder on a Windows, machine, with all files intact...but i'd like to them intact on the Pi in the kitchen - that's why i put it there in the first place!

thanks again!

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24143
Joined: Sat Jul 30, 2011 7:41 pm

Re: corrupted text files

Thu Jan 24, 2013 1:55 pm

hanna wrote:thanks for the reply! just to be clear:
- if i open the file on the Pi itself, it opens with Leafpad and is completely blank.
- if i open the file on the Pi via a Windows machine over the network, it opens with Notepad and is incomplete, missing significant portions of the text.
- if i copy the file from Pi back to a Windows machine, it opens with Notepad and is incomplete.
- i still have the original folder on a Windows, machine, with all files intact...but i'd like to them intact on the Pi in the kitchen - that's why i put it there in the first place!

thanks again!
I have a feeling they are not raw text files as you say that the fonts are wrong. But a raw text files (*.txt) doesn't have the ability to have different fonts. What generated the files?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

hanna
Posts: 19
Joined: Sat Dec 22, 2012 4:25 pm

Re: corrupted text files

Thu Jan 24, 2013 2:12 pm

sorry, should have been clearer - some of the font sizes are off, not the font itself. primary problem however is just an incomplete document with paragraphs, sentences etc missing.

as i notes below, the files were just recipes, blocks of text copied off of websites and pasted into Notepad and saved as .txt files.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24143
Joined: Sat Jul 30, 2011 7:41 pm

Re: corrupted text files

Thu Jan 24, 2013 2:32 pm

hanna wrote:sorry, should have been clearer - some of the font sizes are off, not the font itself. primary problem however is just an incomplete document with paragraphs, sentences etc missing.

as i notes below, the files were just recipes, blocks of text copied off of websites and pasted into Notepad and saved as .txt files.
Hmm. Still odd. Font type, sizes etc are not supported in a raw text file - all you get are characters, and paragraphs are only there because of carriage returns, not through any formatting instructions. If they were cut and pasted from websites, they are perhaps HTML formatted? But then I wouldn't expect things to disappear - just more stuff to appear!

Can you post one of the files to somewhere it can be downloaded - or perhaps can you cut and paste something in to a 'quote' section in here?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: corrupted text files

Thu Jan 24, 2013 7:36 pm

another thing to consider doing is to rename one of the text files to end with the .html extension, and see what it looks like if you view it in a browser on your pi.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

hanna
Posts: 19
Joined: Sat Dec 22, 2012 4:25 pm

Re: corrupted text files

Thu Jan 24, 2013 10:26 pm

ok, see the attached zip file. now, i like to use Greek yogurt instead of regular....wait, what? oh sorry, wrong forum :D

anyway, i put two txt files, before and after being copied over to my Pi, in the attached zip file - not much to see but that should illustrate my problem.

thanks!
text files before and after copied to Pi.zip
(945 Bytes) Downloaded 84 times

efflandt
Posts: 359
Joined: Mon Dec 03, 2012 2:47 am
Location: Elgin, IL USA

Re: corrupted text files

Fri Jan 25, 2013 1:28 am

How did you "import" the folders into the Pi? Windows uses different line endings than *nix systems (carriage return, newline in DOS/Windows vs. just newline in Linux) which can sometimes make text look different or cause problems with scripts.

When I viewed your after example in ghex which shows both hex codes and ascii, the file was a bunch of hex zeros ending with hex 59 6F which in ascii is "Yo".

I usually either use scp to copy files between systems, or use USB memory stick or SD card. But then, I mostly run Linux at home (64-bit Ubuntu 12.04 on my PC).
Last edited by efflandt on Fri Jan 25, 2013 1:29 am, edited 1 time in total.

User avatar
rpdom
Posts: 15583
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: corrupted text files

Fri Jan 25, 2013 1:29 am

Your original file looks to be a normal .txt file (although with CRLF terminators instead of just LF, which is normal for DOS/Windows and shouldn't be a problem).

The "Pi" file is just junk. 512 bytes of NULL followed by "Yo".

Something is definitely corrupting the file.

When you say
i imported a folder full of text (*.txt) documents (recipes, actually) into my Pi
, what did you actually do? Is you Pi set up as a Samba share on your network? What commands/method did you use to get the files on your Pi?

Hopefully we will get to the bottom of this problem.

Incidentally, I tend to use goat yoghurt. This is because my wife can't eat normal yoghurt. :-)

hanna
Posts: 19
Joined: Sat Dec 22, 2012 4:25 pm

Re: corrupted text files

Fri Jan 25, 2013 11:55 am

yup. i set up Samba on the Pi in order to see my shares (and vice versa) on my Windows machines. if i recall, i just copied and pasted the recipe files right into the Public folder on the Pi, via the network . thought i was all set until i actually went to open one of the files (all the file names looked normal.)

not knowing much about Linux, it never occurred to me this could be a problem. so, how would you copy a Windows text file into a Linux?

thanks!

User avatar
Burngate
Posts: 6097
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: corrupted text files

Fri Jan 25, 2013 12:18 pm

I wonder if it's something to do with Linux not writing directly to the SD card, but keeping it in a buffer.
If Samba had allocated space but not written the file, you'd get garbage

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: corrupted text files

Fri Jan 25, 2013 1:28 pm

It should work...

Try copying them again. Check they are right before you switch the Pi off, (and shutdown the Pi properly with "sudo halt".)

If that fails, copy them to a USB drive and back into the Pi from there.

kalehrl
Posts: 350
Joined: Tue Jul 24, 2012 10:49 am

Re: corrupted text files

Fri Jan 25, 2013 1:38 pm

I'm afraid those corrupted text files are a sign of SD card corruption.
I got the same problem when I used Turbo overclocking.
Here is an example of the corrupted file:
Attachments
es_systems.zip
(917 Bytes) Downloaded 65 times

Return to “Beginners”