Splitting a text file into different strings


#1

I currently have a loop creating many different text files of the form
[(Book) (author ) (price)]
I want to split each text file into book, author and price, and then form a data table/csv containing all of the files.
I am having trouble splitting the text file into a string. At the minute I am using the “Read text file” function and then assigning to “Split({environment.newline},StringSplitOptions.RemoveEmptyEntries)”. I get an error message saying that a value of 1-dimensional array of string cannot be converted to Ui.path.generic.core.value.
Is there any way to fix this error? or perhaps a different method to split the string/extract the data?

The end goal of this code is to be able to copy data (book,author,price) from the web and seperate it into 3 individual columns in an excel spreadsheet (book,author,price)

I am a new user so I cannot upload attachments,
My sample data is a text file of the form
Author
Book
Price

I have many text files of this form, which were “scraped”/copied from the internet in a looped recording


#2

please give sample data


#3

Sample data given above.


#4

The “cannot be converted” error usually happens when your variable is a different type as what you are assigning, if that makes sense. So you might check your string variable that stores all the text and make sure it’s a “string” and not a “Generic Value”.

Also, I’m not sure your Split function is right for what you want to do. But if you want to split by just the newline character, it’s .Split(Environment.Newline(0)) … the “{” are only needed if you are splitting using a string or array of characters =)

Hope this helps a little bit.


#5

please change the datatype of your assignment variable to array of string system.string[].