Hi all
Thanks Eric and Tobias for help.
Here is my final code :
[UrlContentScriptCsv]
<script>
var p;
if (document.all){
// For IE, create an ActiveX Object instance
p = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
// For mozilla, create an instance of XMLHttpRequest.
p = new XMLHttpRequest();
}
p.open("GET","$1",false);
p.send(null);
var out = p.responseText;
out = out.replace(/\n$/,"")
out = out.split(";").join("|");
out = "|" + out.split("\n").join("|\n|") + "|";
wikify(out.replace("|\n","|h\n"),place);
</script>
You can place it into attachments like :
[plouf.csv]
!type
application
!file
..\matlab\plouf.csv
!Link
<<tiddler templateNewFileLink with: {{tiddler.title}}>>
!Content
<<tiddler UrlContentScriptCsv with:../matlab/plouf.csv>>
Works with
Win7 / FF43.0
++
JBo
On Friday, December 11, 2015 at 3:41:30 PM UTC+1, Eric Shulman wrote:
>
> 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]
>>
>> <script>
>> ...
>> 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"...
> http://TiddlyTools.github.com/fundraising.html#MakeADonation
>
> Professional TiddlyWiki Consulting Services...
> Analysis, Design, and Custom Solutions:
> http://www.TiddlyTools.com/#Contact
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/a4f5a1f1-8c69-44ed-9e77-87403274b296%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.