Spreadsheet to multiple txt files with specified names

255 views Asked by At

I'm looking for a way to export text from a cells in a spreadsheet into multiple '.txt' files. The trick is that each .txt file would contain text from one cell from specified column and it would be named using text from one cell from other specified column.

Example Spreadsheet:

Names   text    extra-info
John    15684   Spring
Sally   54645   Autumn
Mark    45545   Winter

From this example three .txt files should be created. Named: John.txt Sally.txt Mark.txt

and containing relevant numbers. ex 15684 inside Jonh.txt.

The spreadsheet is a google spreadsheet at the moment but we have access to open office and excel as long as one of them can do that job.

1

There are 1 answers

2
John On

This should be pretty straightforward. Do you know how to begin writing an App Script? I don't mean to sound condescending, but since you didn't post code, I don't know exactly where you need help.

I'd use the Spreadsheet service to gather the data from your spreadsheet:

https://developers.google.com/apps-script/reference/spreadsheet/range#getValues()

Then you'd iterate through each row and create a new file using the createFile() method in DriveApp for the contents:

https://developers.google.com/apps-script/reference/drive/drive-app#createFile(String,String,String)

All of the resulting files will be in the root folder of Drive.