I've had success in sending a google docs file into a google sheets and the spreadsheet managed to fill itself in correctly (it formats the text into a table, very neat)
Below is an example of how I'm formatting my text:
ID, NAME, MOBILE, CITY, COUNTRY, BIRTHDAY,
3, NameGoesHere1, 21 98658 5548, abcity, countryNameHere, 1998-05-02,
6, SomeoneElse Joined Here, 21 98535 1218, whereland, Far far away, 1989-11-15,
5, AnotherCustomer, 21 85482 5245, somecity, Somewhereland, 1999-08-04,
ID, PRICE, STOCK, ASDF, BASDF, CASDF,
ID, NAME, PRICE, DESCRIPTION,
2, pen, 1.5, The pen is mightier than the sword,
3, pencil, 1.0, Can be used to write,
4, RPG, 150.0, well that escalated quickly, huh,
EMPTY,
names,
goofs,
ID, FLAVOR,
(Note that there's two empty tables, the one with "ID, PRICE, STOCK, ASDF, BASDF, CASDF" and "ID, FLAVOR" as their columns, they've been left blank on purpose)
By filling a cell with:
=IMPORTDATA("<<< <<<google drive url containing text goes here, just copy-paste>>> >>>")
I am able to create a several tables with that chosen cell being the top-left of the first table, and that command fits them all into the google sheets format automatically. Each table being placed below the previous one, starting by the column names.
I'm looking for a way to get each table in a different google-sheet page, like this:
page1:
ID, NAME, MOBILE, CITY, COUNTRY, BIRTHDAY,
3, NameGoesHere1, 21 98658 5548, abcity, countryNameHere, 1998-05-02,
6, SomeoneElse Joined Here, 21 98535 1218, whereland, Far far away, 1989-11-15,
5, AnotherCustomer, 21 85482 5245, somecity, Somewhereland, 1999-08-04,
page2:
ID, PRICE, STOCK, ASDF, BASDF, CASDF,
page3:
ID, NAME, PRICE, DESCRIPTION,
2, pen, 1.5, The pen is mightier than the sword,
3, pencil, 1.0, Can be used to write,
4, RPG, 150.0, well that escalated quickly, huh,
and so on.
I would like to know if there's a way to separate text into different pages like shown above, or what's an alternate way to convert the filetype from text to sheets such that I could split it up into different pages
ps.: I need the code to be in python, as I'm working with pydrive for the file uploads
edit.: SOLVED by @Tanaike. Important debugging to look out for @Tanaike's solution:
- SCOPE must be set with a list format, each url in a different list index
- make sure your .txt is formatted with two \n's per PAGE and single \n for next rows.
- if for whatever reason you have invalid credentials, recheck your "credentials.json" or "client_secrets.json" before starting to panic.
I want to thank @Tanaike yet again, for his patience and dedication to my solution and for his help with debugging it.