Hello guys,
I have something basic to do, but I can’t find how…
I read a .txt file with a list of login ID’s and store the data into a string variable :
toto
titi
tutu
And I need to write this data into the specific Login column of a .csv file:
Name,Login,Mail
The other columns are already populated.
How can I achieve that ?
HI @remy2283
use like this str.Split(Environment.Newline.ToCharArray) and use loop to loop through the output array
cheers
Please see below
Input
Output
What to do(filling the data into column2)
str contains the string read from file
dt is the datatable read from CSV
abc.xaml (9.9 KB)
cheers
Hello Anil G, thanks for your quick response.
But your xaml file seems corrupted, I can’t open it.
Hi @remy2283
Can you implement it using the attached screenshot
I am looping through the datatable read from the csv file and then updating the required column
Index is from the for loop properties
str is the string which you read from the text file
You are not able to open may be because of version difference let me know your version if you are not able to recreate xaml using the information
cheers
My version is Studio 2021.10.4
It is better, thanks.
But it is not working, if I execute your script and write a csv, it gives me the same value for the column 2 :
Column1,Column2
text,Titu
yext2,Titu
Text3,Titu
Please include index in the for loop properties as well
like this
I missed while converting
cheers
This is working.
Geez, you are good.
Many thanks
Happy automation.
Can you please close it with solution so that others with similar query can also find it
Cheers
Hello Anil, I come at you.
I adapted your example to my script, but it is working halfway.
My .csv is updated with one line out of two…
Column1,Column2
text,Tito
yext2,
Text3,Titu
Text4,
How do I put the text in separate columns in the CSV file in…
Select the first column (column A)
Click on ‘Data’ and then on ‘Text to Columns’
The option ‘Delimited’ has been preselected. This is the correct option. Click on ‘Next’.
Select the option ‘Comma’ and click on ‘Finish’
Regards,
Will
Main.xaml (11.1 KB)
Hello Anil, here is the file…
Hi @remy2283
Please check the text input you provided is it having a empty line between two names I believe that is the reason you are having a blank item in between
please check the string in notepad is like this
cheers
Hello Anil,
No, there is no empty lines in my txt file.
But I managed to remove the issue with the command
LoginID.toString.Split({Environment.NewLine.ToCharArray},StringSplitOptions.None)(index)
It is working now. Thanks for your tremendous help !
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.