Why is my Google app script creating corrupt zip files?Google Sheet script set cell valueHow to debug Google Apps Script (aka where does Logger.log log to?)How to create custom keyboard shortcuts for google app script functions?Create a new sheet in a Google Sheets with Google Apps ScriptGoogle Apps Script: Zip of folder treeCreate a large zip file in Google Apps ScriptSetting Document Type from App ScriptCreate a copy of a Google Sheet with Google Apps ScriptInsert script file using Google Apps ScriptWith Google Appscript - How to send a automated email using a custom body from a draft template located in Gmail?

Did anybody find out it was Anakin who blew up the command center?

Talk interpreter

Stolen MacBook should I worry about my data?

Why does the `ls` command sort files like this?

Does trying to charm an uncharmable creature cost a spell slot?

What stops you from using fixed income in developing countries?

Can I use coax outlets for cable modem?

Is there an in-universe explanation given to the senior Imperial Navy Officers as to why Darth Vader serves Emperor Palpatine?

What is the name of this plot that has rows with two connected dots?

What is Soda Fountain Etiquette?

Is there any problem with a full installation on a USB drive?

Can a paladin prepare more spells if they didn't cast any the previous day?

Why does this London Underground poster from 1924 have a Star of David atop a Christmas tree?

Biological refrigeration?

Why did James Cameron decide to give Alita big eyes?

Can I get a PhD for developing an educational software?

How do we improve collaboration with problematic tester team?

Term used to describe a person who predicts future outcomes

Can I create something like a macro in Numbers?

How to force GCC to assume that a floating-point expression is non-negative?

What was the point of "Substance"?

Do sharpies or markers damage soft rock climbing gear?

Force SQL Server to use fragmented indexes?

Is there a word or phrase that means "use other people's wifi or Internet service without consent"?



Why is my Google app script creating corrupt zip files?


Google Sheet script set cell valueHow to debug Google Apps Script (aka where does Logger.log log to?)How to create custom keyboard shortcuts for google app script functions?Create a new sheet in a Google Sheets with Google Apps ScriptGoogle Apps Script: Zip of folder treeCreate a large zip file in Google Apps ScriptSetting Document Type from App ScriptCreate a copy of a Google Sheet with Google Apps ScriptInsert script file using Google Apps ScriptWith Google Appscript - How to send a automated email using a custom body from a draft template located in Gmail?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















The zip file that my Google app script creates is "difficult" to open in Window desktop. The zip won't open in File explorer, but I can get it open in the program 7zip. The files are created from columns in Google sheets (of mixed text and numbers). Notepad++ says that they are encoded in UTF-8, and the DXF file has been changed to one line of comma separated values. The file is too large to manually fix since it is normally around 100,000 lines.



If I don't zip the files, the google app script rejects the DXF file as unsupported. The DXF file is text file with a column of text that AutoCAD can interpret. I can change the DXF extension to TXT and email it separately, but I want the file to have the right extension.



Edit (2019-04-02): My current issue is emailing or downloading a usable DXF from the third sheet of the spreadsheet. I can do this manually, but I want to make things as easy as possible for anyone using this file. Eventually, I will modify the generic DXF file with the (x,y) locations of the structures along with the descriptive text for each structure, although the script below does not do that at this time. Thank you!



Edit 2 (2019-04-08): Based on the suggestion, I found some code to format the data into a CSV array: var csv = ""; dxfValues.forEach(function(e1) csv += e1.join(",") + "n";);
Adding this code creates a readable, usable DXF file from a column in Sheets. It handles some of the weirdly formated characters and lines in the DXF file without dropping them or mashing them together.



 var values = ss2.getDataRange().getValues();
var filename = JobNumber + ' Structures Dips ' + new Date().getTime() + ".txt";
DriveApp.createFile(filename, values);

var dxfValues = ss3.getDataRange().getValues();

var dxf_Filename = JobNumber + ' Structures Dips ' + new Date().getTime() + ".dxf"; // DXF file name
var folder = "---folder id---"; // Folder ID

var csv = "";
dxfValues.forEach(function(e1) csv += e1.join(",") + "n";);

var url = DriveApp.getFolderById(folder).createFile(dxf_Filename, csv, MimeType.CSV);

var Dipblob = DriveApp.getFilesByName(filename).next().getBlob();
var DXFblob = DriveApp.getFilesByName(dxf_Filename).next().getBlob();


var zip = Utilities.zip([Dipblob , DXFblob]);


MailApp.sendEmail(
to: "--email address---",
subject: filename,
htmlBody: "Hello <br><br>" + "Here are the generated dip files",
attachments: [zip],
name: 'Scot May'
);
}


I would like to either have an emailed zip file with the text file and the DXF file, or an email that has filename.txt and filename.dxf attached to it. Thanks. ** issue resolved, see above **










share|improve this question





















  • 2





    The fact that Windows Explorer doesn't open the zipfile does not mean it is corrupt. The v-arious Windows Explorer implementations of zip have had gaps from the beginning. They typically have had trouble with large files and spanned files. If 7zip works why not use that?

    – BoarGules
    Mar 27 at 20:49






  • 1





    My goal is to distribute this Google sheet, script, and form to other people in my company. I don't want to force them to use 7zip, for ease of adoption. (edit - also, I didn't know that about Windows)

    – Scot May
    Mar 27 at 21:57







  • 1





    If you are going to distribute, stop right there and create an add-on. You only want to have one thing to update.

    – tehhowch
    Mar 27 at 22:14











  • I will do that.

    – Scot May
    Mar 27 at 22:46











  • Include in your question an example sheet data layout and an example of the correct DXF file that should be created.

    – tehhowch
    Apr 1 at 18:40

















1















The zip file that my Google app script creates is "difficult" to open in Window desktop. The zip won't open in File explorer, but I can get it open in the program 7zip. The files are created from columns in Google sheets (of mixed text and numbers). Notepad++ says that they are encoded in UTF-8, and the DXF file has been changed to one line of comma separated values. The file is too large to manually fix since it is normally around 100,000 lines.



If I don't zip the files, the google app script rejects the DXF file as unsupported. The DXF file is text file with a column of text that AutoCAD can interpret. I can change the DXF extension to TXT and email it separately, but I want the file to have the right extension.



Edit (2019-04-02): My current issue is emailing or downloading a usable DXF from the third sheet of the spreadsheet. I can do this manually, but I want to make things as easy as possible for anyone using this file. Eventually, I will modify the generic DXF file with the (x,y) locations of the structures along with the descriptive text for each structure, although the script below does not do that at this time. Thank you!



Edit 2 (2019-04-08): Based on the suggestion, I found some code to format the data into a CSV array: var csv = ""; dxfValues.forEach(function(e1) csv += e1.join(",") + "n";);
Adding this code creates a readable, usable DXF file from a column in Sheets. It handles some of the weirdly formated characters and lines in the DXF file without dropping them or mashing them together.



 var values = ss2.getDataRange().getValues();
var filename = JobNumber + ' Structures Dips ' + new Date().getTime() + ".txt";
DriveApp.createFile(filename, values);

var dxfValues = ss3.getDataRange().getValues();

var dxf_Filename = JobNumber + ' Structures Dips ' + new Date().getTime() + ".dxf"; // DXF file name
var folder = "---folder id---"; // Folder ID

var csv = "";
dxfValues.forEach(function(e1) csv += e1.join(",") + "n";);

var url = DriveApp.getFolderById(folder).createFile(dxf_Filename, csv, MimeType.CSV);

var Dipblob = DriveApp.getFilesByName(filename).next().getBlob();
var DXFblob = DriveApp.getFilesByName(dxf_Filename).next().getBlob();


var zip = Utilities.zip([Dipblob , DXFblob]);


MailApp.sendEmail(
to: "--email address---",
subject: filename,
htmlBody: "Hello <br><br>" + "Here are the generated dip files",
attachments: [zip],
name: 'Scot May'
);
}


I would like to either have an emailed zip file with the text file and the DXF file, or an email that has filename.txt and filename.dxf attached to it. Thanks. ** issue resolved, see above **










share|improve this question





















  • 2





    The fact that Windows Explorer doesn't open the zipfile does not mean it is corrupt. The v-arious Windows Explorer implementations of zip have had gaps from the beginning. They typically have had trouble with large files and spanned files. If 7zip works why not use that?

    – BoarGules
    Mar 27 at 20:49






  • 1





    My goal is to distribute this Google sheet, script, and form to other people in my company. I don't want to force them to use 7zip, for ease of adoption. (edit - also, I didn't know that about Windows)

    – Scot May
    Mar 27 at 21:57







  • 1





    If you are going to distribute, stop right there and create an add-on. You only want to have one thing to update.

    – tehhowch
    Mar 27 at 22:14











  • I will do that.

    – Scot May
    Mar 27 at 22:46











  • Include in your question an example sheet data layout and an example of the correct DXF file that should be created.

    – tehhowch
    Apr 1 at 18:40













1












1








1








The zip file that my Google app script creates is "difficult" to open in Window desktop. The zip won't open in File explorer, but I can get it open in the program 7zip. The files are created from columns in Google sheets (of mixed text and numbers). Notepad++ says that they are encoded in UTF-8, and the DXF file has been changed to one line of comma separated values. The file is too large to manually fix since it is normally around 100,000 lines.



If I don't zip the files, the google app script rejects the DXF file as unsupported. The DXF file is text file with a column of text that AutoCAD can interpret. I can change the DXF extension to TXT and email it separately, but I want the file to have the right extension.



Edit (2019-04-02): My current issue is emailing or downloading a usable DXF from the third sheet of the spreadsheet. I can do this manually, but I want to make things as easy as possible for anyone using this file. Eventually, I will modify the generic DXF file with the (x,y) locations of the structures along with the descriptive text for each structure, although the script below does not do that at this time. Thank you!



Edit 2 (2019-04-08): Based on the suggestion, I found some code to format the data into a CSV array: var csv = ""; dxfValues.forEach(function(e1) csv += e1.join(",") + "n";);
Adding this code creates a readable, usable DXF file from a column in Sheets. It handles some of the weirdly formated characters and lines in the DXF file without dropping them or mashing them together.



 var values = ss2.getDataRange().getValues();
var filename = JobNumber + ' Structures Dips ' + new Date().getTime() + ".txt";
DriveApp.createFile(filename, values);

var dxfValues = ss3.getDataRange().getValues();

var dxf_Filename = JobNumber + ' Structures Dips ' + new Date().getTime() + ".dxf"; // DXF file name
var folder = "---folder id---"; // Folder ID

var csv = "";
dxfValues.forEach(function(e1) csv += e1.join(",") + "n";);

var url = DriveApp.getFolderById(folder).createFile(dxf_Filename, csv, MimeType.CSV);

var Dipblob = DriveApp.getFilesByName(filename).next().getBlob();
var DXFblob = DriveApp.getFilesByName(dxf_Filename).next().getBlob();


var zip = Utilities.zip([Dipblob , DXFblob]);


MailApp.sendEmail(
to: "--email address---",
subject: filename,
htmlBody: "Hello <br><br>" + "Here are the generated dip files",
attachments: [zip],
name: 'Scot May'
);
}


I would like to either have an emailed zip file with the text file and the DXF file, or an email that has filename.txt and filename.dxf attached to it. Thanks. ** issue resolved, see above **










share|improve this question
















The zip file that my Google app script creates is "difficult" to open in Window desktop. The zip won't open in File explorer, but I can get it open in the program 7zip. The files are created from columns in Google sheets (of mixed text and numbers). Notepad++ says that they are encoded in UTF-8, and the DXF file has been changed to one line of comma separated values. The file is too large to manually fix since it is normally around 100,000 lines.



If I don't zip the files, the google app script rejects the DXF file as unsupported. The DXF file is text file with a column of text that AutoCAD can interpret. I can change the DXF extension to TXT and email it separately, but I want the file to have the right extension.



Edit (2019-04-02): My current issue is emailing or downloading a usable DXF from the third sheet of the spreadsheet. I can do this manually, but I want to make things as easy as possible for anyone using this file. Eventually, I will modify the generic DXF file with the (x,y) locations of the structures along with the descriptive text for each structure, although the script below does not do that at this time. Thank you!



Edit 2 (2019-04-08): Based on the suggestion, I found some code to format the data into a CSV array: var csv = ""; dxfValues.forEach(function(e1) csv += e1.join(",") + "n";);
Adding this code creates a readable, usable DXF file from a column in Sheets. It handles some of the weirdly formated characters and lines in the DXF file without dropping them or mashing them together.



 var values = ss2.getDataRange().getValues();
var filename = JobNumber + ' Structures Dips ' + new Date().getTime() + ".txt";
DriveApp.createFile(filename, values);

var dxfValues = ss3.getDataRange().getValues();

var dxf_Filename = JobNumber + ' Structures Dips ' + new Date().getTime() + ".dxf"; // DXF file name
var folder = "---folder id---"; // Folder ID

var csv = "";
dxfValues.forEach(function(e1) csv += e1.join(",") + "n";);

var url = DriveApp.getFolderById(folder).createFile(dxf_Filename, csv, MimeType.CSV);

var Dipblob = DriveApp.getFilesByName(filename).next().getBlob();
var DXFblob = DriveApp.getFilesByName(dxf_Filename).next().getBlob();


var zip = Utilities.zip([Dipblob , DXFblob]);


MailApp.sendEmail(
to: "--email address---",
subject: filename,
htmlBody: "Hello <br><br>" + "Here are the generated dip files",
attachments: [zip],
name: 'Scot May'
);
}


I would like to either have an emailed zip file with the text file and the DXF file, or an email that has filename.txt and filename.dxf attached to it. Thanks. ** issue resolved, see above **







google-apps-script google-sheets






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 8 at 16:24







Scot May

















asked Mar 27 at 20:37









Scot MayScot May

537 bronze badges




537 bronze badges










  • 2





    The fact that Windows Explorer doesn't open the zipfile does not mean it is corrupt. The v-arious Windows Explorer implementations of zip have had gaps from the beginning. They typically have had trouble with large files and spanned files. If 7zip works why not use that?

    – BoarGules
    Mar 27 at 20:49






  • 1





    My goal is to distribute this Google sheet, script, and form to other people in my company. I don't want to force them to use 7zip, for ease of adoption. (edit - also, I didn't know that about Windows)

    – Scot May
    Mar 27 at 21:57







  • 1





    If you are going to distribute, stop right there and create an add-on. You only want to have one thing to update.

    – tehhowch
    Mar 27 at 22:14











  • I will do that.

    – Scot May
    Mar 27 at 22:46











  • Include in your question an example sheet data layout and an example of the correct DXF file that should be created.

    – tehhowch
    Apr 1 at 18:40












  • 2





    The fact that Windows Explorer doesn't open the zipfile does not mean it is corrupt. The v-arious Windows Explorer implementations of zip have had gaps from the beginning. They typically have had trouble with large files and spanned files. If 7zip works why not use that?

    – BoarGules
    Mar 27 at 20:49






  • 1





    My goal is to distribute this Google sheet, script, and form to other people in my company. I don't want to force them to use 7zip, for ease of adoption. (edit - also, I didn't know that about Windows)

    – Scot May
    Mar 27 at 21:57







  • 1





    If you are going to distribute, stop right there and create an add-on. You only want to have one thing to update.

    – tehhowch
    Mar 27 at 22:14











  • I will do that.

    – Scot May
    Mar 27 at 22:46











  • Include in your question an example sheet data layout and an example of the correct DXF file that should be created.

    – tehhowch
    Apr 1 at 18:40







2




2





The fact that Windows Explorer doesn't open the zipfile does not mean it is corrupt. The v-arious Windows Explorer implementations of zip have had gaps from the beginning. They typically have had trouble with large files and spanned files. If 7zip works why not use that?

– BoarGules
Mar 27 at 20:49





The fact that Windows Explorer doesn't open the zipfile does not mean it is corrupt. The v-arious Windows Explorer implementations of zip have had gaps from the beginning. They typically have had trouble with large files and spanned files. If 7zip works why not use that?

– BoarGules
Mar 27 at 20:49




1




1





My goal is to distribute this Google sheet, script, and form to other people in my company. I don't want to force them to use 7zip, for ease of adoption. (edit - also, I didn't know that about Windows)

– Scot May
Mar 27 at 21:57






My goal is to distribute this Google sheet, script, and form to other people in my company. I don't want to force them to use 7zip, for ease of adoption. (edit - also, I didn't know that about Windows)

– Scot May
Mar 27 at 21:57





1




1





If you are going to distribute, stop right there and create an add-on. You only want to have one thing to update.

– tehhowch
Mar 27 at 22:14





If you are going to distribute, stop right there and create an add-on. You only want to have one thing to update.

– tehhowch
Mar 27 at 22:14













I will do that.

– Scot May
Mar 27 at 22:46





I will do that.

– Scot May
Mar 27 at 22:46













Include in your question an example sheet data layout and an example of the correct DXF file that should be created.

– tehhowch
Apr 1 at 18:40





Include in your question an example sheet data layout and an example of the correct DXF file that should be created.

– tehhowch
Apr 1 at 18:40












1 Answer
1






active

oldest

votes


















1















Probably your issue with the "erroneous" content format in the DXF is resolved by properly creating the file from a 2D array.



As an example, this function converts a 2D array into a CSV:



/**
* Construct a CSV representation of an array. Adds quoting and escaping as needed.
* @param Array[] myArr A 2D array to be converted into a CSV string
* @return string A string representing the rows of the input array, joined by CRLF.
*/
function array2CSV_(myArr)

return myArr.map(_row4CSV).join("rn");

/**
* Ensure the given value is CSV-compatible, by escaping special characters and adding double-quotes if needed.
* @param any value An array element to be encapsulated into a CSV string.
* @return string A string that will interpreted as a single element by a CSV reader.
*/
function _val4CSV(value)
str.indexOf("n") !== -1
/**
* Construct a CSV representation of in the input array.
* @param Array row A 1-D array of elements which may be strings or other types which support toString().
* @return string A string that will be interpreted as a single row by a CSV reader.
*/
function _row4CSV(row)

return row.map(_val4CSV).join(",");




It looks like the DXF format is a single column, so you'd probably join row with " " instead of a comma. Perhaps DXF doesn't also require the same escaping that CSVs do, so your implementation of the value formatter could very well be simpler too.






share|improve this answer

























  • Thanks, I will look into this, and let you know.

    – Scot May
    Mar 27 at 22:00











  • @scot any luck?

    – tehhowch
    Mar 29 at 18:23











  • Not yet. I'm still working on it.

    – Scot May
    Apr 1 at 17:51










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386033%2fwhy-is-my-google-app-script-creating-corrupt-zip-files%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1















Probably your issue with the "erroneous" content format in the DXF is resolved by properly creating the file from a 2D array.



As an example, this function converts a 2D array into a CSV:



/**
* Construct a CSV representation of an array. Adds quoting and escaping as needed.
* @param Array[] myArr A 2D array to be converted into a CSV string
* @return string A string representing the rows of the input array, joined by CRLF.
*/
function array2CSV_(myArr)

return myArr.map(_row4CSV).join("rn");

/**
* Ensure the given value is CSV-compatible, by escaping special characters and adding double-quotes if needed.
* @param any value An array element to be encapsulated into a CSV string.
* @return string A string that will interpreted as a single element by a CSV reader.
*/
function _val4CSV(value)
str.indexOf("n") !== -1
/**
* Construct a CSV representation of in the input array.
* @param Array row A 1-D array of elements which may be strings or other types which support toString().
* @return string A string that will be interpreted as a single row by a CSV reader.
*/
function _row4CSV(row)

return row.map(_val4CSV).join(",");




It looks like the DXF format is a single column, so you'd probably join row with " " instead of a comma. Perhaps DXF doesn't also require the same escaping that CSVs do, so your implementation of the value formatter could very well be simpler too.






share|improve this answer

























  • Thanks, I will look into this, and let you know.

    – Scot May
    Mar 27 at 22:00











  • @scot any luck?

    – tehhowch
    Mar 29 at 18:23











  • Not yet. I'm still working on it.

    – Scot May
    Apr 1 at 17:51















1















Probably your issue with the "erroneous" content format in the DXF is resolved by properly creating the file from a 2D array.



As an example, this function converts a 2D array into a CSV:



/**
* Construct a CSV representation of an array. Adds quoting and escaping as needed.
* @param Array[] myArr A 2D array to be converted into a CSV string
* @return string A string representing the rows of the input array, joined by CRLF.
*/
function array2CSV_(myArr)

return myArr.map(_row4CSV).join("rn");

/**
* Ensure the given value is CSV-compatible, by escaping special characters and adding double-quotes if needed.
* @param any value An array element to be encapsulated into a CSV string.
* @return string A string that will interpreted as a single element by a CSV reader.
*/
function _val4CSV(value)
str.indexOf("n") !== -1
/**
* Construct a CSV representation of in the input array.
* @param Array row A 1-D array of elements which may be strings or other types which support toString().
* @return string A string that will be interpreted as a single row by a CSV reader.
*/
function _row4CSV(row)

return row.map(_val4CSV).join(",");




It looks like the DXF format is a single column, so you'd probably join row with " " instead of a comma. Perhaps DXF doesn't also require the same escaping that CSVs do, so your implementation of the value formatter could very well be simpler too.






share|improve this answer

























  • Thanks, I will look into this, and let you know.

    – Scot May
    Mar 27 at 22:00











  • @scot any luck?

    – tehhowch
    Mar 29 at 18:23











  • Not yet. I'm still working on it.

    – Scot May
    Apr 1 at 17:51













1














1










1









Probably your issue with the "erroneous" content format in the DXF is resolved by properly creating the file from a 2D array.



As an example, this function converts a 2D array into a CSV:



/**
* Construct a CSV representation of an array. Adds quoting and escaping as needed.
* @param Array[] myArr A 2D array to be converted into a CSV string
* @return string A string representing the rows of the input array, joined by CRLF.
*/
function array2CSV_(myArr)

return myArr.map(_row4CSV).join("rn");

/**
* Ensure the given value is CSV-compatible, by escaping special characters and adding double-quotes if needed.
* @param any value An array element to be encapsulated into a CSV string.
* @return string A string that will interpreted as a single element by a CSV reader.
*/
function _val4CSV(value)
str.indexOf("n") !== -1
/**
* Construct a CSV representation of in the input array.
* @param Array row A 1-D array of elements which may be strings or other types which support toString().
* @return string A string that will be interpreted as a single row by a CSV reader.
*/
function _row4CSV(row)

return row.map(_val4CSV).join(",");




It looks like the DXF format is a single column, so you'd probably join row with " " instead of a comma. Perhaps DXF doesn't also require the same escaping that CSVs do, so your implementation of the value formatter could very well be simpler too.






share|improve this answer













Probably your issue with the "erroneous" content format in the DXF is resolved by properly creating the file from a 2D array.



As an example, this function converts a 2D array into a CSV:



/**
* Construct a CSV representation of an array. Adds quoting and escaping as needed.
* @param Array[] myArr A 2D array to be converted into a CSV string
* @return string A string representing the rows of the input array, joined by CRLF.
*/
function array2CSV_(myArr)

return myArr.map(_row4CSV).join("rn");

/**
* Ensure the given value is CSV-compatible, by escaping special characters and adding double-quotes if needed.
* @param any value An array element to be encapsulated into a CSV string.
* @return string A string that will interpreted as a single element by a CSV reader.
*/
function _val4CSV(value)
str.indexOf("n") !== -1
/**
* Construct a CSV representation of in the input array.
* @param Array row A 1-D array of elements which may be strings or other types which support toString().
* @return string A string that will be interpreted as a single row by a CSV reader.
*/
function _row4CSV(row)

return row.map(_val4CSV).join(",");




It looks like the DXF format is a single column, so you'd probably join row with " " instead of a comma. Perhaps DXF doesn't also require the same escaping that CSVs do, so your implementation of the value formatter could very well be simpler too.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 21:21









tehhowchtehhowch

6,7884 gold badges12 silver badges31 bronze badges




6,7884 gold badges12 silver badges31 bronze badges















  • Thanks, I will look into this, and let you know.

    – Scot May
    Mar 27 at 22:00











  • @scot any luck?

    – tehhowch
    Mar 29 at 18:23











  • Not yet. I'm still working on it.

    – Scot May
    Apr 1 at 17:51

















  • Thanks, I will look into this, and let you know.

    – Scot May
    Mar 27 at 22:00











  • @scot any luck?

    – tehhowch
    Mar 29 at 18:23











  • Not yet. I'm still working on it.

    – Scot May
    Apr 1 at 17:51
















Thanks, I will look into this, and let you know.

– Scot May
Mar 27 at 22:00





Thanks, I will look into this, and let you know.

– Scot May
Mar 27 at 22:00













@scot any luck?

– tehhowch
Mar 29 at 18:23





@scot any luck?

– tehhowch
Mar 29 at 18:23













Not yet. I'm still working on it.

– Scot May
Apr 1 at 17:51





Not yet. I'm still working on it.

– Scot May
Apr 1 at 17:51








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386033%2fwhy-is-my-google-app-script-creating-corrupt-zip-files%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript