Cross reference a text file with an excel file - - string

I have a text file with a list of usernames, and I have an excel file with about 4000 rows and about 9 columns. Basically what I'm looking to do is find any instance of anything from the TXT file in the Excel file. The match might not be EXACTLY the same, like :
TXT file has a row monkey1
excel file has a cell in column "C" with \\server1\monkey1
I would like to somehow flag that cell, or even the line in the TEXT file, or a seperate output.
I'm also pretty flexible on how to do this, like VBA/Macros etc. Or even putting this into an Access database or something similar. Or even converting the TXT to CSV or the Excel to another format.
Any advice would be greatly appreciated, or any guidance on what I should be looking for.
Thanks!

Export as csv
Write a python script that reads the csv with the csv module;
and the text file;
and then appends a magic string, like !! to each cell containing the text of a line from the text file;
then outputs a csv file with the updated table;
Then you can import it in excel;
And format-search-and-replace !! into a formatting of background color.

Related

How do I export an Excel data sheet to a .txt file as Delimiter colon?

I have a .txt file that was given to me (exported from a database) that includes columns and rows. I was told some of data was in the wrong column. I just needed to move it to the next column over. I opened the .txt file in Excel using the Data "From Text/CSV" option and made my changes. Once I was finished, I saved my file as a .txt file like it was given to me, however it's not in the same format. My .txt export kept the column and rows whereas the original file given to me had the information had the values separated with "|" characters. Do you know how I can get the data in the "|" format so I can send it back to them? See my screenshots for reference.enter image description here
Once you have opened the file in Excel and made your changes, you can use the steps in below link here to change the delimiter to "|" or anything else you would like...

Can I color the same string in one Excel file or CSV file?

For example, the first and third columns are compared, and if they are the same character string, they are colored.
Repeat this line by line.
I want to know how to do this using python.
It would be nice if you could give me an example.
I do not know how this can done in an excel file. The openpyxl or xlswriter module could be an good starting point -google for python excel module for more).
But for a csv file, I am sorry the the only way is to print it and then use coloured pencils on the printed paper. A CSV file is a plain text file

funny format when copy from CSV

I used python to write some text to csv but it is stored in funny format.
output data is saved here:example data
for example, it is read as the below in csv excel
text shown in CSV
when i copy it to other platforms(notepad, word, web application) it turns into something else
after copy
I tried a numerous method include formatting with the CSV but it just wont work.
Could someone please help me.
With thanks,
Iverson
It's hard to guess what you mean...
Your file has TABs between many characters. But every line starts and ends in a double quote ("). So the whole line is one value (cell).

Automatically convert csv file into Excel table?

I generate some csv files using a script. Next I manually convert those csv files into excel tables using the import wizard in excel based on:
https://www.youtube.com/watch?v=z5Pxil4jVO4
Is it possible to do this automatically - e.g. by calling an excel importer from command line - so I don't need to open excel and do all the manual work?
I can open the csv file directly in Excel but its not formatted as a table. E.g. this csv file:
a,b,c
a,b,c
results in this Excel sheet:
I would like each letter to be in a separate column.
I have looked at this:
https://social.technet.microsoft.com/Forums/windowsserver/en-US/370ee470-f2cd-4f30-a167-b106dd51d47a/powershell-convert-csv-to-xlsx?forum=winserverpowershell
but its an awful lot of boiler plate code from create a simple table.
Add an extra line to your CSV file to tell Excel what the seperator is. Add the following line to the top of your CSV file:
sep=,
The easiest way, without close and edit your file - you can choose which separator you want in Excel 2010-2016 go to DATA, Text To Columns, choose Delimited, then choose your separator Comma (or other) and you will see changes immediately in the "Data preview", then click FInish.
Once you have the format you wanted, you simply save the document and it will be permanent.

Outputting to CSV via .txt --looking for more elegant solution

I've recently written a few python scripts that count the number of words in a csv file and then print as output two columns: "Prefix" and "Count" where prefix is the first word in a name in a row and count is the sum of all occurences of that name.
My question is that if I try to output to a .csv file directly, everything gets put in one column and it doesn't look nice. However, if I output first to a .txt file, and then open that file in excel such that it asks me to make a space delimiter, it looks correct. I bet the answer is pretty basic, but I'm just wondering if there is a simpler way to do this than saving as a .txt and then re-opening as a .csv. Additionally, why can I open a new excel file and open the .txt file from there and it works, whereas if I try to just "open with" the .txt file directly into excel it does not work (and instead gives me the old result with everything in one column)?
Much thanks for any help you can provide!
EDIT:
Output looks like the following when I open the .txt file as a csv with the "open with" button:
Word Count
the 333
Family 54
When I open a new excel file and open the .txt file from there and use the delimiter options that come up before the file opens, it looks correctly like this:
Word, Count
the, 333
Family, 54
CSV = comma separated values
You need to output the data separated by comma and not space. You can save this as .csv and double-click to open in excel. Then the data appears in two columns.
Additionally, why can I open a new excel file and open the .txt file from there and it works, whereas if I try to just "open with" the .txt file directly into excel it does not work (and instead gives me the old result with everything in one column)
Same reason. If you open a .txt file in excel, it will just open as text. It doesn't know how to interpret this data (what goes into which columns). When you "open a new excel file and open the .txt file from there", you are "importing" the data and you tell excel to interpret the data as two columns with space as delimiter, so it works.
You can also open the .txt file directly in excel using "open with" and then use the "Text to Columns" feature to remodel the data in a spreadsheet-friendly way.

Resources