I am looking for particular text in a column in data, if the text exists, I want to return True if not false.
This is the code I have:
Test = if(containsstring(DS[Name]=".SA"),"T","F")
I have tried it with wildcards and no wild cards.
Any help would be appreciated
Replace your = with a comma ,.
Test = IF ( CONTAINSSTRING ( DS[Name], ".SA" ), "T", "F" )
Related
consider that i have data in excel (B1=2, B2=5, B3=7, ... ) and ( A1=2 , A2=3)
i want to make a formula in C1 = B(A1) + B(A2) whitch result in 12 for this case
i tried B$A1 and B[A1] and B"A1" and ... all other things, not any chance
can you help me
hello
consider that i have data in excel (B1=2, B2=5, B3=7, ... ) and ( A1=2 , A2=3)
i want to make a formula in C1 = B(A1) + B(A2) whitch result in 12 for this case
i tried B$A1 and B[A1] and B"A1" and ... all other things, not any chance
can you help me
With EXCEL-365 try-
=SUM(INDEX(B1:B3,A1:A2))
So my goal here is to filter for 2 service code(there will be hundreds in a single column) but in this case I need "4" and "CO4" that is the letter o capitalized not the number zero. FYI
Issues/Goals:
4 and CO4 have a space in them like CO4(space) this varies as in some may not have the space. Humans..am I right? lol
Filtering in an addition column called 'Is Void' for False values with the above two service codes.* this is where I believe my issue is
2a) this is because I lose a lot of data about 1700 rows with that code I will show in a bit.
Sample Data base:
My code: This has everything imported and data base in open too.
dfRTR = dfRTR[["Zone Name", "End Time", "Is Void", "Ticket Notes", "Service Code", "Unit Count", "Disposal Monitor Name", "Addr No","Addr St", "Ticket Number"]] #Columns I will use
dfRTR.replace("CO4 ","CO4") #Takes out (space) in CO4
dfRTR.replace("4 ", "4") #Takes out (space) in 4
filt = dfRTR[(dfRTR['Is Void'] == False) & (dfRTR["Service Code"].isin(["CO4 ", "4"]))] #my problem child.
If I take this code out I have all my data, but with it only about 700-800 Rows which is supposed to be around 1500-2000k Rows in the column "Is Void".
I have only been coding for about two months, not knowing how to replace two values at once in the same column, is another topic. I am trying to automate my whole audit which can take 4hrs to 2-3days depending on the project. Any advice is greatly appreciated.
EDIT:
So, if i manual make my exccel all text then run this code:
dfRTR['Service Code'] = dfRTR['Service Code'].str.replace(r'\W', "")
filt = dfRTR[(dfRTR['Is Void'] != True) & dfRTR["Service
Code"].isin(["CO4","4"])]
filt.to_excel('VecTest.xlsx')
And I can return all my data I need filtered. Only down side is that my date will have text formatting. I will try to automate one column in this case 'Service Code' to be text then run it again.
Edit part 2: Making the above file in a CVS mas the filtering process way easier. Problem is converting it back to an excel. Excel formulas have an issue with simple formula like =A1=B1 if both cells A1 and B1 have a value of 1 they will not match. CVS pulls away all the extra "Formatting" but in the Excel VBA code I use to format it make the cell give off this warning, even though the data being pulled is from CVS format.
VBA code makes the values appear with the excel warning:
"The number in this cell is formatted as a text or preceded with an apostrophe"
Conclusion:
I would need to make all my check using python before using CVS formatting.
I figured it out. My solution is a function but it does not need to be:
def getRTRVecCols(dfRTR):
# this is majority of special chars that may be in columns cells
spec_chars = ["!", '"', "#", "%", "&", "'", "(", ")",
"*", "+", ",", "-", ".", "/", ":", ";", "<",
"=", ">", "?", "#", "[", "\\", "]", "^", "_",
"`", "{", "|", "}", "~", "–"]
# this forloop will remove all those special chars for a specific column
for char in spec_chars:
dfRTR["Service Code"] = dfRTR["Service Code"].str.replace(char, ' ')
#with the above we may get white spaces. This is how to remove those
dfRTR["Service Code"] = dfRTR["Service Code"].str.split().str.join(" ")
# take in multiple values for in one column to filter for (specific for me)
codes = ["CO4", "4"]
#filtering our data set with multiple conditions. 2 conditions is in the same single column and another condition in a differnt column
dfRTR = dfRTR[(dfRTR["Is Void"] != True) & (dfRTR["Service Code"].isin(codes))]
#saves to a excel file
dfRTR.to_excel('RTR Vec Cols.xlsx')
#my function call
getRTRVecCols(dfRTR)
Now I Do get this warning, which I am still to noob in python to understand yet. But is next on my list to fix. But it works perfect for now*
FutureWarning: The default value of regex will change from True to False in a
future version. In addition, single character regular expressions will*not* be treated as literal strings when regex=True.
dfRTR["Service Code"] = dfRTR["Service Code"].str.replace(char, ' ')
I have some doubts, i want to replace the values in column for the values of the other one, i have my query like this
= Table.ReplaceValue(#"Renamed Columns1", each ["Alcance-Canal"], null , Replacer.ReplaceValue,{"CANAL/ES"})
however it still doesn't work, could you please assist me?
Regards
Easiest thing to do is add a custom column with formula
= if [columnname] = "something" then [columnname] else [othercolumnname]
or
= if [columnname] = "something" then "anotherthing" else [othercolumnname]
FormAnswer:
A(email) | B(name)
Students:
A(name) | B(uid)
What I want
If 1234#domain.com is registered on page FormAnswer: A(email)
Look at Students for "1234" in B(uid) and grab value of A(name) and
Then write this in FormAnswer: B(name)
This works - but only for first row
IF( ISNUMBER( FIND( (LEFT(F1:F;LEN(F1:F)-10)) ; (Elever!C1:C) ) ) ; (Elever!B1:B) ; "Elevens navn mangler" )
What I want, Vol II
Code looking through entire column accordingly with new signups.
Any ideas?
This is a guess based on the information at hand:
=ArrayFormula(IFERROR(VLOOKUP(REGEXEXTRACT(F:F;"^(.+?)#");{Elever!C:C&""\Elever!B:B};2;0);"Elevens navn mangler"))
I want to use xlsread in MATLAB to read an Excel file.
While I know which columns I want to read from, and which row I want to start reading from, the file could contain any number of rows.
Is there a way to do something like:
array = xlsread( 'filename', 'D4:F*end*' ); %% OR ANY SIMILAR SYNTAX
Where F*end* is the last row in column F?
Yes. Try this:
FileFormat = '.xls' or '.xlsx'; % choose one
% ( by default MATLAB
% imports only '.xls' )
filename = strcat( 'Filename you desire', FileFormat );
array = xlsread( filename ) % This will read all
% the Matrix ( by default
% MATLAB will import all
% numerical data from
% file with this syntax )
Then you can look to the size of the matrix to refine the search/import.
[nRows,nCols] = size( array );
Then if the matrix you want to import just parts of the matrix, you can do this:
NewArray = xlsread( filename, strcat( 'initial cell',
':',
'ColumnLetter',
num2str( nRows )
)
);
% for your case:
NewArray = xlsread( filename, strcat( 'D3', ':', 'F', num2str( nRows ) ) );
Hope this helps.
In xls format excel files, 65536 seems to be limit of number of rows that you can use. You can use this number with F and that will basically tell MATLAB to search till the end of file. That's all I could gather from little digging up work on these and this trick/hack seems to work alright.
To sum up, this seems to do the trick for xls files -
array = xlsread('filename', 'D4:F65536')
For xlsx files, the limit seems to be 1048576, so the code would change to -
array = xlsread('filename', 'D4:F1048576')
External source to confirm the limit on number of rows -
Excel versions 97-2003 (Windows) have a file extension of XLS and the
worksheet size is 65,536 rows and 256 columns. In Excel 2007 and 2010
the default file extension is XLSX and the worksheet size is 1,048,576
rows and 16,384 columns.
You could read column by column:
col1= xlsread( 'filename', 'D:D' );
col2= xlsread( 'filename', 'E:E' );
col3= xlsread( 'filename', 'F:F' );
...
Don't provide row numbers (such as D12:D465), Matlab will deal with D:D like you would expect. col1, col2 and col3 will have different sizes depending on how much data was extracted from each column.
I haven't tried something like this thought, I don't know if it would work:
colAll= xlsread( 'filename', 'D:F' );
No, But...
MATLAB does not have either documented or undocumented feature for doing this directly.
The maximum one can use under direct MATLAB support is to:
___ = xlsread(filename,-1) opens an Excel window to interactively select data.
Select the worksheet, drag and drop the mouse over the range you want,
and click OK.
This syntax is supported only on Windows systems with Excel software.
Still, how to approach the task efficiently and future-proof?
The "blind" black-box approach would be to first test the boundary of the contiguous area, where your data is present -- use any feasible iterator, first forward-stepping by doubling a blind-test step-distance of a tested cell alike aRowToTEST = ( aRowToStartFROM + aRowNumberDistanceToTEST ) and in case the tested cell contains a number, set aLastNonEmptyROW = aRowToTEST; double the aRowNumberDistanceToTEST and repeat.
In case aRowToTEST points "behind" the format-specific maximum row number, set aRowToStartFROM = aLastNonEmptyROW; and reset the forward-stepping distance aRowNumberDistanceToTEST = 1; to continue forward-stepping iterations with a doubling-step stepping. If this again hits the limit, having the step == 1 and yet pointing right "behind" the format-specific limit, your sheet-under-review contains data until its last row ( finishing on the format-specific "edge" ).
But once the target cell is empty/NaN, stop the forward-stepping phase and start a standard back-stepping phase by halving the interval between a found/failed ( empty ) cell aFirstEmptyROW = aRowToTEST; and the last known cell at aLastNonEmptyROW, that contained number.
Again, if a cell under test contained a fair value, move the aLastNonEmptyROW-boundary to aRowToTEST value, if not, move the same way aFirstEmptyROW-boundary.
Finally set aBackSteppingSTEP = ( aFirstEmptyROW - aLastNonEmptyROW )/2; aRowToTEST = aFirstEmptyROW - aBackSteppingSTEP;.
Iterate the above until your step is < 1 and thus you have iteratively found the contiguous data-area boundary.
This is way faster and incomparably more efficient than a raw-dumb-import-whole-sheet and works until both a 64k or 1M or any further upper-limit of an XLS rowNumber.
Having the boundary, simply array = xlsread( 'filename', 'D4:F<<aLastNonEmptyROW>>' );