Find an 8 digit stock number within a cell
I am looking to create a formula that enables me to search a set of data for an 8 digit number. I have attached my testing sheet.
In column B is the stock numbers I need to find within a set of data.
In column E is the full list to be checked against, however, within any one cell, you can have several different 8 digit stock numbers.
In my test sheet, I have found that a vlookup only searches for the first stock number and not all the stock numbers within that cell. I have attempted an index match formula combined with a transpose split however none of these has enabled me to properly search my data set.
=ARRAYFORMULA(VLOOKUP(B2:B,$E$2:$E,1,0))
then
=INDEX($E$2:$E$1139,(MATCH(B2,TRANSPOSE(SPLIT($E$2:$E,";, ")))))
The data can be separated within the cell with either spaces or "," or ";"
You should be able to make a copy of my test sheet using this link:
Hope you can help.
1 answer
-
answered 2022-05-04 10:28
player0
try:
=FILTER(E:E, REGEXMATCH(E:E&"", TEXTJOIN("|", 1, B2:B)))
update:
to get true/false use:
=INDEX(REGEXMATCH(E2:E&"", TEXTJOIN("|", 1, B2:B)))
or if you want to return match or N/A use:
=INDEX(IF(REGEXMATCH(E2:E&"", TEXTJOIN("|", 1, B2:B)), E2:E, ISNA()))
do you know?
how many words do you know
See also questions close to this topic
-
Is there a way to instead of re-downloading a file simply open the already downloaded file?
I frequently have to reopen files from a link, or find it somewhere on the downloads folder. It is not that important and far too many downloads to properly save and sort them for when I will or will not need later.
So is there a way to simply make firefox (or chrome) open the already downloaded file instead downloading it again ?
-
HTML5 video tag fails to display high resolution videos
I have a simple webpage with a
<video>
tag. I tried assigning thesrc
attribute of the video tag with URLs of two different videos, both about 2 and a half seconds long:The first video has a frame resolution of 3840x2160. JSFiddle: https://jsfiddle.net/u2sgawk7/2/
The second video has a frame resolution of 4096x2160. JSFiddle: https://jsfiddle.net/u2sgawk7/3/
I'm encountering a problem with the second video when loading the webpage from Google Chrome on my mobile device (Galaxy S10). The first JSFiddle works perfectly fine on all devices. The second JSFiddle seems to work fine on desktop browsers, but simply displays a blank white screen when I open it on my mobile device (on Google Chrome for example).
I've tested this functionality using many other video files, and it is clear that the frame resolution is the decisive factor here: the problem occurred with every single video with a resolution of 4096x2160, and only with these videos.
I tried using this website: https://clideo.com/crop-video, to test whether or not it is even possible to display high resolution videos on mobile. I uploaded the second video (the one that was causing a white screen), and it was successfully displayed using a video tag on that website - both on desktop and on mobile!
What am I doing wrong? Any help to resolve this would be appreciated.
Once again just to clarify:
The issue does not happen on desktop browsers at all.
The issue does not happen on FireFox on my Galaxy S10.
The issue happens on every other browser I tried on my Galaxy S10, as well as in Safari on iPhone.
-
It won't let me run selenium code in IntellJ all of a sudden
I was going to execute my code, which is the one I always execute every day for my tests, but suddenly this error appears and I have hardly found a solution, I don't know if it is possible that you can help me with that, I attach the response from the console
Starting ChromeDriver 102.0.5005.27 (df4a85108ffad4dca2c409c52f24df7ec0204b91-refs/branch-heads/5005_22@{#4}) on port 33567 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 102 Current browser version is 101.0.4951.54 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'DESKTOP-V4H61F7', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.2' Driver info: driver.version: ChromeDriver remote stacktrace: Backtrace: Ordinal0 [0x003B2733+2434867] Ordinal0 [0x003407A1+1968033] Ordinal0 [0x0022C678+837240] Ordinal0 [0x0024CAC3+969411] Ordinal0 [0x002486DA+952026] Ordinal0 [0x00245F91+941969] Ordinal0 [0x002790B0+1151152] Ordinal0 [0x00278D0A+1150218] Ordinal0 [0x00274256+1131094] Ordinal0 [0x0024E840+976960] Ordinal0 [0x0024F736+980790] GetHandleVerifier [0x00623C72+2515426] GetHandleVerifier [0x0061702F+2463135] GetHandleVerifier [0x0045522A+620442] GetHandleVerifier [0x00454016+615814] Ordinal0 [0x0034707B+1994875] Ordinal0 [0x0034B938+2013496] Ordinal0 [0x0034BA25+2013733] Ordinal0 [0x00354DE1+2051553] BaseThreadInitThunk [0x7632FA29+25] RtlGetAppContainerNamedObjectPath [0x77E87A7E+286] RtlGetAppContainerNamedObjectPath [0x77E87A4E+238] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62) at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:1002) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123) at Selenium.pruebas_activity21.main(CrearOT.java:28) Process finished with exit code 1
I hope you can help me with it. It doesn't say any relevant changes, but it seems that any code I'm trying to do can no longer be executed.
-
PERCENTILE IF using ARRAYFORMULA for a set of conditions
I need to calculate the percentile using an if condition to calculate it by group of conditions, but Google Sheets doesn't provide PERCENTILEIF function. A nonarray solution is possible:
=ARRAYFORMULA(PERCENTILE(if(range=value,values),percentile))
but in my case
value
should be an array of possible values.Here is the sample data with the expected result highlighted:
I tried several options to use an array of possible values, but in all cases, I get the wrong result:
Using
JOIN
inG2
:=arrayformula(if(len(E2:E3),percentile(split(regexreplace(join(",", Arrayformula(A2:A12 & "_" & B2:B12)),E2:E3 & "_(\d+)|.",",$1"),","),D2),))
Using
MATCH
inH2
:=ARRAYFORMULA(if(len(E2:E3), PERCENTILE(IFNA(--(match(A2:A12,E2:E3,0) > 0) * B2:B12,),D2),))
here is the Spreadsheet file: https://docs.google.com/spreadsheets/d/1VDJIYvmOC46DI_9u4zSEfmxSan5R5VKK772C_kP5rxA/edit?usp=sharing
-
How do I show Popup Message everytime I go to another Sheet using Google Sheet/Apps Script?
I have 3 sheets in a workbook - Sheet1, Sheet2, and Sheet3, every time I change to a Sheet there is a Popup message that will show up.
What I had in mind...
function onOpen() { var ui = SpreadsheetApp.getUi(); ui.alert('This is my pop up message!'); }
-
Move row to a different sheet when box is checked
Hi I'm very new to coding with Google Sheets and Excel. My goal is to move a row when it is checked off.
The original sheet is called "School Assignments" and the sheet I want to move it to is called "Finished". When a box in column H (column 8) is checked the data value of the row becomes "Done". When it is not marked it is "Unfinished".
I want the row to move to the Finished sheet when I mark it as "Done". I also want this to work vice versa where when I uncheck and it becomes "Unfinished" it it goes back to the School Assignments sheet. I have some code but honestly it was done months ago (I'm coming back to this project after a break) and I'm not sure what I was thinking when I wrote it or if it is correct at all. It doesn't work obviously.
if(sh.getName() == "School Assignments" && e.range.columnStart == 8 && e.value == "Done") { let tsh = e.source.getSheetByName("Finished"); sh.getRange(e.range.rowStart, 1, 1, sh.getLastColumn()).moveTo(tsh.getRange(tsh.getLastRow() + 1, 1)); sh.deleteRow(e.range.rowStart); } else if(sh.getName() == "Finished" && e.range.columnStart == 8 && e.value == "Unfinished") { let tsh = e.source.getSheetByName("School Assignments"); let trg = tsh.getRange(tsh.getLastRow() + 1, 1); sh.getRange(e.range.rowStart, 1, 1, sh.getLastColumn()).moveTo(trg); sh.deleteRow(e.range.rowStart); } }
I also have an auto-sorting piece earlier in the code which defines some constants.
const ss = SpreadsheetApp.getActiveSpreadsheet() const ws = ss.getSheetByName("School Assignments") const range = ws.getRange(2,1,ws.getLastRow()-1,8) range.sort({column: 7, ascending: true }) }
I am totally unsure how to fix this and accomplish what I'm looking to do.
-
In Mongo, If a document I'm saving "Prateek" then I don't want on the next create operation even the "prateek" or "praTEEK", etc is saved
//** If I'm adding a new document with the name: "India", then I don't want that the DB allow another name with the name: "INDIA", "india", "indIA", etc. I'm new and learning, help would be great!!**
// Controller
var Dinosaur = require('../models/dinosaurs'); //addDino module.exports.addDino = (req, res) => { var name = req.body.name; var type = req.body.type; var height = req.body.height; var weight = req.body.weight; var Period = req.body.Period; req.checkBody('name', 'Name is required').notEmpty(); var errors = req.validationErrors(); if (errors) return res.status(400).send({ message: 'Name is Required' }); else { let newDino = { name: name, type: type, height: height, weight: weight, Period: Period } Dinosaur.addDino(newDino, (err, result) => { if (err) { if (err.name) return res.status(409).send({ message: name + ' Already Exist' }); else if (err.url) return res.json({ status: false, error: { url: "Url already exist" }, message: err.url }); else return res.json(err, "Server Error"); } else { return res.status(200).send({ message: "Done" }); } }); } }
// Model
var mongoose = require('mongoose'); //dinosaur schema var DinosaurSchema = mongoose.Schema({ name: { type: String, unique: true }, type: { type: String }, height: { type: Number }, weight: { type: Number }, Period: { type: String } }); var Dinosaur = mongoose.model('dinosaur', DinosaurSchema); //add module.exports.addDino = (query, callback) => { Dinosaur.create(query, callback); }
// GetAll, Already Created a new document with the name "Brachiosaurus"
// > Create, a new create with the first letter lower case "brachiosaurus", Don't want it to be pushed.
-
Update column values based on another dataframe's index
I have the following dataframes:
NUMS = ['1', '2', '3', '4', '5'] LETTERS = ['a', 'b', 'c'] df1 = pd.DataFrame(index=NUMS, columns=LETTERS) a b c 1 NaN NaN NaN 2 NaN NaN NaN 3 NaN NaN NaN 4 NaN NaN NaN 5 NaN NaN NaN df2 = pd.DataFrame([['tom', 10], ['nick', 15], ['james', 14]], index=LETTERS, columns=['col', 'col2']) col col2 a tom 10 b nick 15 c james 14
I'm trying to update
df1
withdf2
so that if the column matches the index fromdf2
, all rows are updated withcol2
:a b c 1 10 15 14 2 10 15 14 3 10 15 14 4 10 15 14 5 10 15 14
I've tried
df1.update(df2['col2'])
, butdf1
does not update.I've also tried
df1.apply(lambda x: df2['col2'].loc[x])
, but I'm getting the following error:KeyError: "None of [Float64Index([nan, nan, nan, nan, nan], dtype='float64')] are in the [index]"
Thank you!
-
How to delete certain number from a list in list using the index in python?
I have a list in a list, and I am trying to delete the third number of each sublist, but every time I am getting an error
TypeError: list indices must be integers or slices, not list
a = [[0.0, 0.0, 0.0], [0.19, 0.36, 0.0], [0.24, 0.42, 0.0], [0.16, 0.08, 0.0], [0.05, -0.57, 0.0] ]
Desired result:-
a_updated = [[0.0, 0.0], [0.19, 0.36], [0.24, 0.42], [0.16, 0.08], [0.05, -0.57] ]
In the second part of my code, I wanted to merge this sublist according to a dictionary shown below, for example, the first value of dictionary:-
1: [1, 2]
shows the merging of 1st and 2nd values i.e.[0, 0, 0.19, 0.36]
.I guess this part of my code is right!
dict_a = { {1: [1, 2], 2: [2, 4], 3: [3, 5], 4: [4, 5] }
my attempt:-
dict_a = { 1: [1, 2], 2: [2, 4], 3: [3, 5], 4: [4, 5]} a = [[0.0, 0.0], [0.19, 0.36], [0.24, 0.42], [0.16, 0.08], [0.05, -0.57]] # first part for i in a: for j in a[i]: del j[2] print(j) #second part a_list = [] list_of_index = [] for i in dict_a: index= [] a_list.append(index) for j in dict_a_updated[i]: print(j-1) index.extend(a_updated[j-1]) print('index',index)
Error output -
file "D:\python programming\random python files\4 may axial dis.py", line 18, in <module> for j in X[i]: TypeError: list indices must be integers or slices, not list
-
Reverse words in a string in C++
Can anyone please tell that why the below written code isnt working , theres no error but its simply printing the string which was passed and is not reversing it.
Logic: First reverse individual words and after reversing all the words in a string simply reverse the entire string.
I/P : hello world O/P : world hello
Below is the code:
#include <bits/stdc++.h> using namespace std; void reverse(string str,int low, int high){ while(low<=high){ swap(str[low],str[high]); low++; high--; } } void reverseWords(string str){ int start=0; int n = str.length(); for(int end=0;end<n;end++){ if(str[end]==' '){ reverse(str,start,end-1); start=end+1; } } reverse(str,start,n-1); reverse(str,0,n-1); cout<<str; } int main() { string s = "Welcome to Gfg"; cout<<"After reversing words in the string:"<<endl; reverseWords(s); return 0; }
-
creating a list from a column with multiple lines
I have a Pandas data frame that in one column called SourceDocument I have multiple lines of data in each cell (separated by \n).
SourceDocuments
PRDS-002039\nPRDS-001952\nPRDS-001956
I would like to run a for loop that reads each row and then separates these lines into a list. Eventually, I wanna have a dictionary where the value is the list of split items. for example:
SourceID
546785: ['PRDS-002039','PRDS-001952','PRDS-001956']
The dict keys(546785) are generated through another for loop I wrote the below code but can't figure out how to do the split row-by-row
valuez=[] for j in range (0,ABP215.shape[0]): valuez.append(ABP215['SourceDocuments'][j].split('\n'))
APB215 is the Pandaas dataframe name.
I get this error:
AttributeError: 'float' object has no attribute 'split'
any help would be appreciated.
-
How can I transform rows to columns?
I have this table with data below and need help because I don't know which formula can I use to convert the table into the desired one.
I don't know if it's possible with
ARRAYFORMULA
,QUERY
orTRANSPOSE
Current Data Set:
Date E1 E2 E3 4/01/2021 4,17% 3,53% 3,16% 11/01/2021 4,40% 3,69% 3,58% 18/01/2021 4,93% 4,39% 4,10% Expected Output:
Date Type Metric 4/01/2021 E1 4,17% 4/01/2021 E2 3,53% 4/01/2021 E3 3,16% 11/01/2021 E1 4,40% 11/01/2021 E2 3,69% 11/01/2021 E3 3,58% 18/01/2021 E1 4,93% 18/01/2021 E2 4,39% 18/01/2021 E3 4,10% -
Excel - multiple value search across multiple columns or one column with multiple values
I have 7 criteria = TMO-1 through to TMO-7
I have two scenarios to search from.
i have either got a single excel with TMO-6, TMO-201, TMO-67,... etc (some have a lot of values)
or i have split the cell up so the values are all in individual cells such that [TMO-6][TMO-201][TMO-67] etc
I have tried two equations from each. for the first one (the preferred solution) i have tried:
=IF(IFERROR(SEARCH("TMO-1",AB8),0) > 0, "TMO-1",IF(IFERROR(SEARCH("TMO-2",AB8),0) > 0, "TMO-2", "false"))
the problem with that is it finds anything that starts with TMO-1, so will show true if TMO-12 is in the cell.
For option 2 i tried:
=IF(AB9:AR9=TMO-1, TMO-1, IF(AB9:AR9=TMO-2, TMO-2, IF(AB9:AR9=TMO-3, TMO-3,IF(AB9:AR9=TMO-4, TMO-4, IF(AB9:AR9=TMO-5, TMO-5, IF(AB9:AR9=TMO-6, TMO-6, IF(AB9:AR9=TMO-7, TMO-7, "N/A")))))))
and i get the error #spill
any ideas ?
-
Trouble when trying to do a VLOOKUP like with two pandas dataframes
I've read a lot of questions regarding this matter, but none of it solved my problem.
I have 2 dataframes, one containing a list of all students of graduation level in a country, each one (each row) with informations about the student itself, as well as the course code.
On another dataframe, i have a list of unique course codes containing the address of the university that is assigned to the course code.
df1 CodCourse|Student|Address 1 10 outdated address 2 11 outdated address 2 12 outdated address 3 13 outdated address 3 14 outdated address 4 15 outdated address 4 16 outdated address df2: CodCourse Address 1 Xth avenue 2 Yth avenue 3 Zth avenue 4 Nth avenue Expected result: df1 CodCourse|Student|Address 1 10 Xth avenue 2 11 Yth Street 2 12 Yth Street 3 13 Zth Street 3 14 Zth Street 4 15 Nth Street 4 16 Nth Street
I want to update the dataframe 1 address column with the address column of the dataframe 2.
I'm doing like this, but it's not working. I've tried with join and using a dictionary, but all I have is a failure.
df1=df1.merge(df2[['CodCourse','Address']], on='CodCourse', how='left')
Please, can anyone help me?
Thanks! Eduardo.
-
Vlookup exact match is not found
I am trying to run a Vlookup to find the account name related to the ID. I have checked the format on both tabs, and it's the same, nevertheless the Vlookup is not working even if the value exists in both tabs.
This is my formula
VLOOKUP(L24,'Zuora Invoices 02/05/2022'!B:D,1,false)
Basically,the cell L24 would be the ID in sheet #1 and in the sheet #2 "Zuora invoices I have column D with the same ID and the column B with the corresponding account name.
With control F I am able to find the exact same value in the sheet #2 but the Vlookup result is #NA. If I try VLOOKUP(L24,'Zuora Invoices 02/05/2022'!D:D,1,false) then the Vlookup finds the ID value.
How can I make it work, so I can find the account name by comparing the account IDs?
Best