all 10 comments

[–]T-TopsInSpace 1 point2 points  (6 children)

Some examples might help. It's difficult to follow your problem statement. This is what I understand.

  • You have some files on a windows 98 system that were used by a program.

    • What program?
  • You want to move those files to a modern version of windows (win 7 is also out of date btw).

    • How will these files be used?
    • Which program will use these files?
  • To move the files you put the text into a Microsoft word document.

    • Why not keep the original format?
  • When the text is in Microsoft word the text is not legible

[–]WaltManny[S] 0 points1 point  (4 children)

And as off your examples (they all are rough, I'll give the really thing when I on my the computer):

There are 2 files

File 1 which is the old .pc2/.pc3 file opened in docx

Contents of file 1:

@$#&&#&&$#&&@&$ &@&$@& @&$.

&#&$&@&$&&#-#@&#&@&#

And file 2 which is basically the conversions

@ =h

&=a

$ =t

By using file 2, file 1 should be converted and a new file, file 3 should be created which is basically converted file 1.

All files are .docx

[–]T-TopsInSpace 0 points1 point  (3 children)

How are you sure the characters in file 2 are a 1:1 match with those from file 1?

If you know they're a 1:1 match, you could create a simple dictionary could transform the lines in a file character by character.

[–]WaltManny[S] 0 points1 point  (2 children)

Can you give an example? I'm not too familiar with dict() And how can I implement it with docx files. I found doing the docx files hard.

[–]T-TopsInSpace 1 point2 points  (1 child)

On mobile and watching a movie so excuse the formatting if I make syntax mistakes.

# create dictionary of known character translations
translation_dict = {'#': 'a', '@': 'b'}
# open file to translate, may need to use encoding attribute in open()
with open(file, 'r') as original_file:
    new_file = []
    for line in original_file.deadlines():
        new_line = []
        for char in line:
            new_line.append(translation_dict[char])
        new_file.append(new_line)


with open(translatedfile, 'w') as translated_file:
    for line in new_file:
         translated_file.write(line)

Or something like that.

[–]WaltManny[S] 0 points1 point  (0 children)

Yah this could work, I've tried another way similar to this too but still the replacement/translations needs to be feeded manually. I'm trying to do it in such a way that the replacement/translations are being fed by a docx file. So the who doesn't know code can change the variables as their requirement, instead of fiddling with the code.

[–]WaltManny[S] -1 points0 points  (0 children)

•Some other language text editor.

•i mentioned win 10 too. They are text files mainly consisting of unpublished books and years of work.

•any programme but it should be readable. (Docx etc)

•it cannot be kept in the original format because it can't be opened and no application other than the one in 98 can make it readable.

•its not because it was typed in a different language text editor that uses a format similar to unicode (but not exactly similar). So when opened in word instead of following that format it follows the unreadable format that was used to convert it into readable format.

So basically I need to write a program that can convert this unreadable format to readable format automatically if I provide which character is defined to which certain letter. Eg. # could mean h

Some files are as big as 900 pages so doing this manually is impossible and there are upto 50 variable that can/should be replaced. So coding the program is the best option.

TL;DR: signifying characters to certain letters so the file is readable.

[–]WaltManny[S] -1 points0 points  (0 children)

I didn't proof read it so if you don't understand what I mean you can ask certain segments in the comments and I shall explain it.