On Friday, December 11, 2015 at 3:38:39 AM UTC-8, julien23 wrote:
Hi all
I wrote this script to display CSV from URL : [UrlContentScriptCsv]
var out = p.responseText.split("\n");
out = out.join("|\n|");
out = out.split(";");
wikify(out.join("|"),place);
</script>
- first line misses a "|" at the begening
- last lines is a lonely "|"
It seems that what you are trying to do is to make each line into a table row, where the input data is delimited by semi-colons.
To achieve this, there are three actions to apply:
* change all ";" to "|"
out = out.split(";").join("|");
* add "|" to beginning and ending of each line
out = "|" + out.split("\n").join("|\n|") + "|";
* if the input data includes a trailing newline, then there will be an extra "|" at the end of the output. To avoid this, remove the trailing "\n"
out = out.replace(/\n$/,"");
Combining these three actions into one line:
out = "|" + out.split(";").join("|").replace(/\n$/,"").split("\n").join("|\n|") + "|";
That should do it. Let me know if you get stuck.
enjoy,
-e
Eric Shulman
ELS Design Studios
TiddlyTools - "Small Tools for Big Ideas!"
InsideTiddlyWiki: The Missing Manuals
YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions: