compare 2 string with multiple results - excel

There are 2 files containing strings. The first strings in the first file are contained in the second file. So as an example there is the file which contains the following elements: table, apple and house. And in the second file there is tableleg, tabletop, applerings, applecake, and so on. Now the second file should be searched for table and the result should be the tableleg and tabletop. Is there a function for it or is Excel VBA needed?
I tried it with the following =VLOOKUP("*C3*";'File2'!A:A;1;0). That works well only unfortunately he only gives me one result per element.

Related

Automatically update the file path of Vlookup to the newest workbook added to a folder

Hello each month we receive a series of monthly returns from different accounts which go into a designated folder based on the account name. Each return has the new month's returns appended to all the previous monthly returns. I am running a vlookup function on my workbook based on the specific return I am looking for. Is it possible to change the source on the vlookup function so it takes the data from the most recently added file in the folder, that way it will contain all the most recent return data with all the previous returns?
Thanks
There are many ways to do that. The first step should be to connect to the designated folder. You should see then something like this:
Option 1: If the file contains the month
If your file contains the month you can use it to extract this information. Following the example above you could:
extract the first 7 charactes and parse it to a date.
sort the date in descending order, so the latest file will be on top
use keep rows to get rid of the rest of files
with the last file remaining, expand the content
Option 2: Use file properties
When you connect to a folder you can see the field "Date created". Use this the same way as explained in option 1.
Option 3: Remove duplicates
If for whatever reason the two options above are not possible, depending on your data you can:
join all files which will lead to duplicates
filter duplicates
This third option might not work if you could have two registers which look the same (all columns in the row have the same value) can appear in your dataset.

How can I add comments at the top of data file that I have created using savetxt function in python 3.0?

Using the savetxt function, I created a data file named as 'output.dat' to which two arrays were written as two different columns. So the file output.dat contains 2 columns of data. Now I want to add headings at the top of each column that would help me to remind what the file contains when I refer back the file later. Say, I want to put the heading 'Time' on the top of the first column and 'Voltage' on the top of the second. How can I do this?

find lines from one file in another efficiently

I have two files referencing some objects, the first file contains a label and a corresponding id value on each line as follows:
label : 123456789
anotherlabel : 987654321
yetanotherlabel : 567891234
The second file contains a subset of records from file one that meet certain criteria, but it only lists the ID. It's a flat one column list as follows
987654321
123456789
I want to make a third file that will contain one column listing the labels from the first file that correspond to the ids from the second file. So in this example it would be
anotherlabel
label
These files are fairly big so I'm looking for an efficient solution. How should I go about this?
Thanks!
You can upload file 2 into hashtable(if it fit into the memory), and thereafter iterate file 1, and parse. If ID match, then print for appropriate ID.

How to Extract different subset of data in text file and pass each subset into another text file?

I have few text files, and I need to subset the subheading data and content of that subheading data and pass to another file.
The text file looks like this
Notes
1. content
2. here also there will be some content till n lines
rule Note
1. n line content (a) for every section
Add Notes
(a) some content
other Note
1. the rest of file
***Code***
with open(file,encoding='utf8') as in_file:
s = in_file.read()
for i, char in enumerate(s):
if s[i:i+5] == 'Notes':
break
for j in range(i,0,-1):
if s[j] == '\n':
break
rest_of_file = s[j+1:]
The above code extract the data from text file from Notes.
so my expected output some thing looks like this in 1st iteration and need to pass to another file
Notes
1. content
2. here also there will be some content till n lines
2nd iteration
rule Note
1. n line content (a) for every section
3rd iteration
Add Notes
(a) some content
final iteration
other Note
1. the rest of file
Note: This is one file which has all subheadings with patter but it may not be same for all the text files. some files may miss Notes ,some may miss rule Note and Add Notes,some files may have directly other note like that it may happen
only common pattern i found here is Note
any approach is fine can any one help with this pls...
ready to work with beautiful soup also
The approach for this is
passed everything into list
if Note appears in items get index of item into list
based on indexes list separate it with different sections
sample code is here:
how to get subset of list from index of list in python

Sorting txt data files while importing in Excel Data Query

I am trying to enter approximately 190 txt datafiles in Excel using the New Query tool (Data->New Query->From File->From Folder). In the Windows explorer the data are properly ordered: the first being 0summary, the second 30summary etc.
However, when entering them through the query tool the files are sorted as shown in the picture (see line 9 for example, you will see that the file is not in the right position):
The files are sorted based on the first digit instead of the value represented. Is there a solution to this issue? I have tried putting space between the number and the summary but it also didn't work. I saw online that Excel doesn't recognize the text within "" or after /, but I am not allowed to save the text files with those symbols in their name in Windows. Even when removed the word summary the problem didn't fix. Any suggestions?
If all your names include the word Summary:
You can add a column "Extract" / "Text before delimiter" enter "Summary", change the column type to Number and sort over that column
If the only numbers are those you wish to sort on, you can
add a custom column with just the numbers
Change the data type to whole number
sort on that.
The formula for the custom column:
Text.Select([Name],{"0".."9"})
If the alpha portion varies, and you need to sort on that also, you can do something similar adding another column for the alpha portion, and sorting on that.
If there might be digits after the leading digits upon which you want to sort, then use the following formula for the added column which will extract only the digits at the beginning of the file name:
=Text.Middle([Name],0,Text.PositionOfAny([Name],{"A".."z"}))

Resources