.txt file export to a Google sheet

Hello
i have a txt file in my phone containing datas. it is a 2D list
txt
i need to upload this list into a Google sheet

what will be the best way how to do it if i have more than 500 lignes

Actualy i am sending my liste column by column using this methode

https://groups.google.com/forum/#!starred/mitappinventortest/RUpJhf8IJgk

but i can upload only 80 lignes

You could upload the file using the base64 method, then get the file ID, and use this formula in a spreadsheet:

=importdata("https://drive.google.com/uc?id=1AU9CGYie1b45bx1Zbdyblky7kbPmReE7")

but there must be another way…(my original method - the one you are using - was not intended for larger datasets - it is probably timing out the script)

I’ll see what else I can come up with…

Try this:

Google Web App Script (bound to spreadsheet):

function doPost(e) {
var data = eval(e.postData.contents) ;
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName('Sheet1');

for (var i=0;i<data.length;i++) {
sh.appendRow(data[i]);
}

return ContentService.createTextOutput("Success") ;
}

Blocks

For large data uploads, you might need to do it in batches.
Here is an obsolete example from AI2’s Fusion Table days …

It works by maintaining a queue of records awaiting upload, and requires an event telling the app that the current batch was uploaded successfully, and with detailed row count increments so we can know how many records we can remove from the front of the upload queue before sending the next batch.

You would have to do something similar in your Google Scripts.

I took the quick route using appendRow. If we know the size of the data (e.g. no columns and rows), which we can get with google apps script, then it is possible to paste the entire dataset in one call.

setValues();

i did the same thing than you and it is not working????

b4
b1

function doPost(e) {
var data = eval(e.postData.contents) ;
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName("Spots");

for (var i=0;i<data.length;i++) {
sh.appendRow(data[i]);
}

return ContentService.createTextOutput("Success") ;
}

is this because i have Latitude and longitude in my datas?

return ContentService.createTextOutput(data) ; do not return any good this

but if i do
var data = e.postData.contents ;
return ContentService.createTextOutput(data) ;
it will return my liste?????

what will be the code using setValues
i know the size of my data there is 100 rows.

Working OK for me.

Base data in text file (using the format you first showed!):

Mon Aug 03 2020,45.90266,6.68621,Frank,0,SpotFranck.svg
Mon Aug 03 2020,45.90266,6.68621,Frank,0,SpotFranck.svg
Mon Aug 03 2020,45.90266,6.68621,Frank,0,SpotFranck.svg
Mon Aug 03 2020,45.90266,6.68621,Frank,0,SpotFranck.svg
Mon Aug 03 2020,45.90266,6.68621,Frank,0,SpotFranck.svg
Mon Aug 03 2020,45.90266,6.68621,Frank,0,SpotFranck.svg
Mon Aug 03 2020,45.90266,6.68621,Frank,0,SpotFranck.svg
Mon Aug 03 2020,45.90266,6.68621,Frank,0,SpotFranck.svg
Mon Aug 03 2020,45.90266,6.68621,Frank,0,SpotFranck.svg

Spreadsheet:

In your blocks you are adding “double quotes” to everything. This is probably breaking the list format.

If you want to remove them from your existing data file use this:

blocks (7)