Sign in to follow this  
Followers 0
mentosan

replace strings based on Excel file

2 posts in this topic

Hi guys

I'm having a text file and an Excel file. The text file is in this manner:

aaaaabbbccc

aaabbbccccddd

addfgfghjkkkk

gghhhjjklmm

...and so on

The Excel file contains 2 columns. The first column contains all the strings from the text file, but not in the same order. The second column contains other strings, every string match a string in the first column:

aaabbbccccddd | aaaaa22544488

aaaaabbbccc | 111222333zzzcc

......

So I'm looking for a script/code which can generate another text file based on the first text file where strings are replaced using the rules found in the Excel file. the result txt file would be like this:

111222333zzzcc

aaaaa22544488

Thank you.

Share this post


Link to post
Share on other sites



Hi guys

I'm having a text file and an Excel file. The text file is in this manner:

aaaaabbbccc

aaabbbccccddd

addfgfghjkkkk

gghhhjjklmm

...and so on

The Excel file contains 2 columns. The first column contains all the strings from the text file, but not in the same order. The second column contains other strings, every string match a string in the first column:

aaabbbccccddd | aaaaa22544488

aaaaabbbccc | 111222333zzzcc

......

So I'm looking for a script/code which can generate another text file based on the first text file where strings are replaced using the rules found in the Excel file. the result txt file would be like this:

111222333zzzcc

aaaaa22544488

Thank you.

You need three arrays:

1. Read the text file into the first array

2. Read the Excel sheet into the second array

3. Create the third array to hold your results

Loop through the first array, and find each item in the second array.

Copy the required cell from the second array to the third.

When the loop through the first array is done, all the matching data will be in order in the third array.

Start coding it, and if you get stuck post your code and get more help.

If you are "looking for a script/code" then you are on the wrong forum. This forum is here to help you write it yourself.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0