I have all data being imported into one cell as:
"<blank space><email address><blank space><CustomerId><blank space><(email address)><line break for next entry>"
Example:
email1#provider.com 12345678 (email1#provider.com)
email224#provider.com 23902490 (email224#provider.com)
I need to extract only the customer ID's, while separating them with a comma, so I tried the following: regexreplace(A2,"([^[:digit:]])",","), however, this also extracts the numbers associated with the emails, so it returns me:
,,,,,1,,,,,,,,,,,,,,12345678,,,,,,,1,,,,,,,,,,,,,,
,,,,,224,,,,,,,,,,,,,,23902490,,,,,,,224,,,,,,,,,,,,,,
Since the email address is set by the user, I don't have control how many digits or if only digits are used in it. I can't seem to understand how to isolate the CustomerIds alone.
Please help!
Edit1:
CustomerID: 64-bit int field, randomly assigned to a client, therefore checking by the length of the string would not work.
Edit2:
For now, I am using the formula below, but I would still be interested in a solution using Regex.
filter(transpose(split($B$4," ")),isnumber(transpose(split($B$4," "))))
If they are separated by a space you should be able to set the space to be your delimiter and extract from there.
https://zapier.com/blog/split-text-excel-zapier/
use:
=ARRAYFORMULA(TEXTJOIN(", ", 1, IFERROR(REGEXEXTRACT(A1:A2, "(?s)(\d{8})"))))
I have a dumped(.rem) file with 3 entries per line, separated by tabs - "\t" as shown below.
Hello World Ocaml
I like Ocaml
To read from this file, the type is passed in a cast(attrbs) along with the file like this:
type attrbs = list (string * string * string);
let chi = (open_in file : attrbs) in
let v = input_value chi in close_in chi
Now, I get a list in "v", which I use further. In fact, it also works if the entries are separated by space.
This works fine if all the 3 entries in a row do not contain any spaces within themselves. I would like to use another file which has the first entry as a string with spaces, second entry as a string without spaces, and third entry as any string as shown below:
This is with spaces Thisiswithoutspaces Thisissomestring
Another one with spaces Anotheronewithoutspaces AnotherString
If I use the code mentioned, since it does not differentiate between space and tab, it takes only the first three words - "This", "is", and "with". I want it to include the spaces and consider "This is with spaces" as an entire string.
I tried searching the web, but couldn't find any solution for it.
Update:
The issue was with the way I read them. If I use specific formats like "%s %s %s", they will work only if we add the # character like "%s#\t%s#\t%s". It is given under the title: "Scanning indications in format strings" in https://caml.inria.fr/pub/docs/manual-ocaml/libref/Scanf.html. The issue is solved.
Glad you managed to do this yourself.
However, I wouldn't recommend using Scanf for that. You can do this:
match String.split_on_char '\t' (input_line chi) with
| [a;b;c] -> ...
| exception End_of_file -> ...
| l_wrong_size -> ...
This way, you are not only sure to not rely on the quirky behavior of Scanf, but you can also easily specify what to do on malformed input.
The issue was with the way I read them. If I use specific formats like "%s %s %s", they will work only if we add the # character like "%s#\t%s#\t%s". It is given under the title: "Scanning indications in format strings" in https://caml.inria.fr/pub/docs/manual-ocaml/libref/Scanf.html. The issue is solved.
I have managed to write some code that can read from a .txt file, however I want my program to only read in important data.
For example, if my text file had the following data:
Name= Samuel
Favourite colour= Green
Age= 24
Gender= Male
I want my program to just read, and ignore everything before the "="
Samuel
Green
24
Male
I looked into the .substr() method, however, you need to know the exact position of the = sign.
This is my code, and it does not work
while ( getline (open_file,line) ){
for (int i=0; i<line.length(); i++){
if (line == "="){
cout << " " + (rest of the line;
}
I would really appreciate it if someone could help me out.
The most efficient way to read in data files is to read in a line at a time into a string variable. Next, extract the important parts.
Your data file looks like it is of the format:
<name> = <value>
I suggest you extract both name and value as strings (e.g. substrings), then you can pass the original data, in its original form, to other functions. Let the other functions worry about converting into integers or other data types.
The name field can be found by searching for the '=' and remembering the position of the '='. Next use the substring method and extract from the beginning of the string to the position before the '='.
The value is the substring that starts after the position of the '=' to the end of the string.
I'll let you look up the std::string functions and how to use them. I don't want to give you the code because you won't learn as much (such as how to look up functions).
See also std::getline.
I have been wanting to extract a line of text once [1],[2] ... [n] is found. But it seems like I couldn't get my thinking out to store a line into a char starting with [1].
void ExtractWebContent::filterContent(){
char str [10];
ifstream reading;
reading.open("file_Currency.txt");
while (!reading.eof()){
reading.get(str,10,'[1]');
cout << str << endl;
}
cout << str;
reading.close();
}
This is the file that I want to extract from..
CAPTION: Currencies
Name Price Change % Chg
[80]USD/SGD
1.2606 -0.00 -0.13%
USD/SGD [81]USDSGD=X
[82]EUR/SGD
1.5242 0.00 +0.11%
EUR/SGD [83]EURSGD=X
I am using linux, C++ programming. This is meant to filter figures obtained from HTML text file.
Any help would be very much appreciated. Thank you!
The big error you have is that you treat a single character as a string. The third argument is supposed to be a single character delimiter, i.e. a character that separates records in the file. If you add the compiler option -Wall when compiling you will get a warning about having more than one character in the single-character literal.
One way of doing what you want, is to use regular expressions.
How do you get the number of spaces before a string starts in ColdFusion?
I mean, I have a string like this " Hello World!"
I want to get the count of spaces (in this case 3) before the word "Hello" starts.
I'm not too familiar with ColdFusion but considering this API you should be able to get the result you want with:
Len(str) - Len(LTrim(str))
But maybe there is a better solution :)