Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Corrupted File Help

  • 27-01-2011 12:55AM
    #1
    Registered Users, Registered Users 2 Posts: 1,129 ✭✭✭


    Hi Guys,

    Bit of help needed. My friend who is doing a 4th year thesis at the minute rang me an hour ago desperately asking for help to try recover a windows works document (.wps), why they were using this and not backing up files is another issue. I've followed all the instructions I can to try recover it but to no avail.

    I have however managed to extract all of the vital text into a .txt file. The problem is that there is a space between every letter in each word and then three spaces between each word where there should be a single space. If I can get this cleaned up it should be a simple copy paste to get it back into standard format. Here's a short example of what i mean where each underscore denotes a space.
    _F_i_g_u_r_e___3_:___C_o_m_p_a_r_i_s_o_n___b_e_t_w_e_e_n___t_h_e___s_t_r_u_c_t_u_r_e___o_f___t_h_e

    Undoubtedly there's an easy way to do this *nix style so if anyone could give any help that'd be great.


    Edit: Literally just after i posted it I thought of a handy way to do this using gedits search replace. I search replace " " and replaced it with ~ and then search replaced " " and replaced it with nothing. I then search replaced ~ and replaced it with a space and hey presto, nice and readable.


Comments

  • Moderators, Arts Moderators Posts: 36,236 Mod ✭✭✭✭pickarooney


    I'm not sure but I think this comes about as a result of switching between UNIX and DOS text formats. There's a command called unix2dos and one called dos2unix which switch text files between the two. But you seem to have used some good logic to fix it :)


  • Registered Users, Registered Users 2 Posts: 1,110 ✭✭✭Skrynesaver


    pljudge321 wrote: »
    Hi Guys,

    Bit of help needed. My friend who is doing a 4th year thesis at the minute rang me an hour ago desperately asking for help to try recover a windows works document (.wps), why they were using this and not backing up files is another issue. I've followed all the instructions I can to try recover it but to no avail.

    I have however managed to extract all of the vital text into a .txt file. The problem is that there is a space between every letter in each word and then three spaces between each word where there should be a single space. If I can get this cleaned up it should be a simple copy paste to get it back into standard format. Here's a short example of what i mean where each underscore denotes a space.



    Undoubtedly there's an easy way to do this *nix style so if anyone could give any help that'd be great.


    Edit: Literally just after i posted it I thought of a handy way to do this using gedits search replace. I search replace " " and replaced it with ~ and then search replaced " " and replaced it with nothing. I then search replaced ~ and replaced it with a space and hey presto, nice and readable.

    Glad you found a method but consider sed or even Perl when you need to make repetitive edits to text.
     sed 's/__/ /g; s/_//g'  corrupt_file.txt
    


Advertisement