PDA

View Full Version : CSV Table Paster Community Extension - Early Access release



lokiare
October 27th, 2017, 01:04
Note: that this is a community extension and not supported by Fantasy Grounds or Smiteworks USA, LLC.

MODERATOR: See an update to this extension (with permission) detailed here: https://www.fantasygrounds.com/forums/showthread.php?40821-CSV-Table-Paster-Community-Extension-Early-Access-release&p=444593&viewfull=1#post444593

This extension allows you to copy the contents of a CSV file (comma delimited) and then 'paste' it into any formattedtext field/control as a table. You can also overwrite the contents of a roll table.

To use it:

Copy the contents of the CSV to the clipboard (CTRL+C or similar)
Open the window that contains the formatted text field/control or the roll table window (if its already open, close it and re-open it).
If you are pasting to a formatted text field, type "#table#" without quotes on a new line where you want the table to show up.
Click the dark green hammer and gear icon at the top left of the desktop.
Click the Convert Clipboard button


Important

Version Notes
V 0.2.0

Initial Release


Let me know if you encounter any bugs, and what they are (copy paste into post please).

Bidmaron
October 27th, 2017, 01:22
This should be very useful, Iokiare!

LordEntrails
October 27th, 2017, 01:47
How does this compare to this one that was just posted yesterday; https://www.fantasygrounds.com/forums/showthread.php?40812-5E-Table-Importer

damned
October 27th, 2017, 02:13
Hi lokiare1 - I cant get it to work... Im messing up the instructions or something else...

specifically Im doing the following.

highlight my csv text and copy (tried copying from notepad and from within FG)
opening a new story entry, adding ##table## on a new line
click the hammer and click convert clipboard

i dont see any update...

my csv text is (pseudo random text, dont try and read any pyscho-babble unto it!)
One,Fall
Two,Jump
Three,Run
Four,Dive
Five,Climb
Six,Count
Seven,Spell
Eight,Fight

lokiare
October 27th, 2017, 20:34
The entry should read "#table#" all lowercase without quotes. I'll take a look at this to see if adding roll tables stopped it from pasting normal tables.

It also only tracks the most recently opened window that has a formattedtext field or control in it. So be sure and open that window (you may have to close and re-open it to set it as the selected window).

In the future I'm going to look at selecting the window by clicking on it instead.

Here is a video to show the process (you can't see me copy the text because its offscreen)

vimeo.com/240217900

lokiare
October 27th, 2017, 20:50
How does this compare to this one that was just posted yesterday; https://www.fantasygrounds.com/forums/showthread.php?40812-5E-Table-Importer

Differences:


That one is limited to the 5E ruleset, this one works on any CoreRPG ruleset.
This one sets the first line of the CSV as the labels.
This one can paste tables into any window that has a formattedtext field/control (i.e. items, spells, etc...etc...)

LordEntrails
October 27th, 2017, 23:36
Differences:


That one is limited to the 5E ruleset, this one works on any CoreRPG ruleset.
This one sets the first line of the CSV as the labels.
This one can paste tables into any window that has a formattedtext field/control (i.e. items, spells, etc...etc...)


Great, thanks for educating me. Look forward to getting to a project on my list that can use this.

damned
October 27th, 2017, 23:48
Ok so they are both CoreRPG - this one creates inline tables for use in formatted text fields. The other creates rollable tables.
It does work for me now using #table# instead of ##table##
What do you mean by the first line is used as labels? On my test runs all cells look like <tr> and no <th>


ahhhh tried pasting in a rollable table and it also did paste but in my test the first row appeared as a label
the 2nd and third rows split nicely into columns, but rows 4-8 put everything in column 1.
Also it seems to make an arbitrary decision to assign 2 values to each roll (eg 1-2, 3-4, 5-6).

lokiare
October 28th, 2017, 01:21
Ok so they are both CoreRPG - this one creates inline tables for use in formatted text fields. The other creates rollable tables.
It does work for me now using #table# instead of ##table##
What do you mean by the first line is used as labels? On my test runs all cells look like <tr> and no <th>


ahhhh tried pasting in a rollable table and it also did paste but in my test the first row appeared as a label
the 2nd and third rows split nicely into columns, but rows 4-8 put everything in column 1.
Also it seems to make an arbitrary decision to assign 2 values to each roll (eg 1-2, 3-4, 5-6).

Can you provide a screenshot and the input text you copied? I'll take a look.

Yeah, it is programmed to do the 2 values, its expected that the user will have to modify the numbers.

In the next update I might have it do the table header in formattedtext fields/controls as well.

Myrdin Potter
October 29th, 2017, 00:35
I find it amusing that two solutions to entering tables appear (and I have been entering a lot of tables and I have a lot more table entry in frommof me).

This one makes story entry easy, the other one makes rollable tables. Both are really appreciated.

Laerun
November 3rd, 2017, 13:05
Hello and well met! I have been using your very helpful tool to import shareable tables at Chartopia. They have formed an indirect partnership with Fantasy Grounds College to help cross promote one another. I have definitely been speaking with Rob2e as a fellow DM and ally in all these community driven projects... PLEASE keep this type of useful and creative tool up to date and visible! Bring all of the communities together...! https://m.facebook.com/story.php?story_fbid=933763863430988&id=846871682120207


Chartopia (https://www.d12dev.com/en/search/) charts and tables can be imported into:

https://www.fantasygrounds.com/forums...868#post362868

https://www.fantasygrounds.com/forums...Table-Importer

Bidmaron
November 3rd, 2017, 14:49
I am not a member of Facebook and never will be. Your link has an entry that is not very informative. What is Chartopia overall?

Laerun
November 3rd, 2017, 19:26
I am not a member of Facebook and never will be. Your link has an entry that is not very informative. What is Chartopia overall?

Informative, maybe not. Useful, for some. I am the founder of Fantasy Grounds College community. Chartopia is a community driven website and app where you can make, save, and share RPG tables. I am going to use these community resources, extensions, and creations in our Discord community for games, content creation, and creativity. I have found tools to help create tables quicker, easier, funner, and as a team. I support this extension, I think it's awesome and I was trying to share that spirit of community and knowledge here...

Laerun

Bidmaron
November 3rd, 2017, 21:18
Dang sounds like something I'd really like to be involved in, but I don't like Facebook at all.

Laerun
November 3rd, 2017, 22:05
It us just simply where I posted something related so that it can be seen here within the community but it does not have to be through Facebook because we have Twitter we have Discord and we have a whole bunch of other media Outlets including our own website called fantasygroundscollege.net
I'm not sure what you are referring to as being part of however if you want to join fgc or fantasy grounds College we have a Discord server and if you go to the website I listed above you can join us and help us out!
Although made mainly we are 5th edition, we are trying to get some of the other genres out so that it can be prevalent in our Discord server.

damned
November 3rd, 2017, 22:59
Hi Bidmaron see the website here: https://www.d12dev.com/en/collection/4/

Ken L
November 4th, 2017, 15:17
Works great.

I had a script awhile ago that did something with the clipboard I forget what exactly.

Edit: found it (https://www.fantasygrounds.com/forums/showthread.php?38730-Pasting-XML&highlight=)

It seems that I could do something similar to pre-process and insert xml.

Myrdin Potter
January 6th, 2018, 03:42
Is it possible to use something other than , in the CSV?

LordEntrails
January 6th, 2018, 04:08
Is it possible to use something other than , in the CSV?
CSV = Comma Separated Values *G*

You can always open it in NPP or something else and replace whatever else you are using with a comma.

Don't know if Lokaire can change the extension :)

lokiare
January 6th, 2018, 06:50
CSV = Comma Separated Values *G*

You can always open it in NPP or something else and replace whatever else you are using with a comma.

Don't know if Lokaire can change the extension :)

At the moment I'm busy with Starfinder, so it will be a while before I can get back to any extensions. Sorry :)

Myrdin Potter
January 6th, 2018, 06:54
The reason why I asked is because many tables I convert have short paragraphs in them and every comma messes it up.

I would love to make the trigger ~ or similar and preserve text with commas in their own cell.

I understand about Starfinder keeping you busy.

damned
January 6th, 2018, 07:08
As mentioned you can replace your commas with something else and then swap them back in the output file or you can crack open the extension and change the separater(sp) definition in the extension...

Myrdin Potter
January 7th, 2018, 04:38
I am very appreciative of the extension as is. I can open up the db.xml in N++ and figure out how to do a global search and replace for whatever I replace the , with, but I am much better in Word and Excel to prepare the file in advance. So I was just hoping.

I find it incredibly nice how much other people share their extensions and rulesets here. Really great community that way.

Bidmaron
January 7th, 2018, 15:03
For anyone interested in the other recent table extension by Celestian, you can find it here (https://www.fantasygrounds.com/forums/showthread.php?40812-5E-Table-Importer).

That extension (contrary to the thread title) works in any CoreRPG ruleset, and it lets you paste any text into a single column table. The gotcha on this one is that PDF text that has line breaks in it will show up as one table roll entry for every line.

Bidmaron
January 7th, 2018, 15:03
Chartopia (https://www.d12dev.com/en/search/) charts and tables can be imported into:

https://www.fantasygrounds.com/forums...868#post362868

https://www.fantasygrounds.com/forums...Table-Importer

Those links don't work.

Bidmaron
January 7th, 2018, 15:06
It seems that I could do something similar to pre-process and insert xml.

When I can get my Generators extension fully tested, you will be able to import xml tables, provided they are in FG format. If you have the details on some alternate format and it isn't too bizarre, I will look at making them import as well.

celestian
January 7th, 2018, 23:22
This extension sounds brilliant! Thanks for writing and sharing it.

Going to try it out ;) Wondering if I can export from adobe pdf a table as cvs and it work in this... if so... OMG ;)


The reason why I asked is because many tables I convert have short paragraphs in them and every comma messes it up.

I would love to make the trigger ~ or similar and preserve text with commas in their own cell.



I didn't know of this extension till today but... I suspect it could be coded to use <tab> or <comma> as a divider tho im not sure that would help your situation.

Myrdin Potter
January 7th, 2018, 23:28
CSV can be set to pretty much any character to replace comma in excel. Like ~.

Now You just need to replace all the commas you want to keep with another character, import them, and then open up the XML and search and replace all the characters you used with comma.

I am not great in N++, and always worry about opening an XML file that FG relies on, but it is certainly doable.

celestian
January 7th, 2018, 23:43
CSV can be set to pretty much any character to replace comma in excel. Like ~.

Now You just need to replace all the commas you want to keep with another character, import them, and then open up the XML and search and replace all the characters you used with comma.

I am not great in N++, and always worry about opening an XML file that FG relies on, but it is certainly doable.

I was more thinking of hacking the extension to do it ;) Either use tab or , or maybe have a selection option. That said I've not opened the extension to see what he's done but it's certainly just character matching.

damned
January 8th, 2018, 00:37
I was more thinking of hacking the extension to do it ;) Either use tab or , or maybe have a selection option. That said I've not opened the extension to see what he's done but it's certainly just character matching.

You can do it in the extension...
But Im sure you know that... more clarification for Myrdin Potter

celestian
January 8th, 2018, 06:47
So this got me thinking so I began playing with this a bit... mainly on the "how to get tables out of a PDF" side mostly.

So what I found out is you need Adobe Pro DC to "export with formatting" and then paste the table into Excel.

Then you can save that as a csv file OR you can select the block and copy. However the control-c/copy method uses <tab> instead of comma. For me however tab is a better option because as Myrdin mentioned lots of text uses commas.

I might play with the extension over the week and see if I can tweak it a bit to have a option for either. I might also see if I can get it to "right click/import" at the point your at instead of the #table# thing...

I was amazed how easy it was to pull a table from the AD&D 1e DMG doing this (the big random magic table). Great stuff you've done here Lokiare.

celestian
January 9th, 2018, 02:35
So FYI, right now FG strips out <tab> so it's not an option to use as a delimiter. Very unfortunate because my copy/table and paste uses them ;( You can use extra steps to get around it for now tho.

DM Patrick
March 26th, 2018, 06:24
So as someone that knows only how to navigate NPP and Excel, and learned what CSV means from this thread, is there a way to:

copy a table from a website
paste it into excel/npp (I can get the data I want into individual cells)
copy the table from excel/npp and paste it using this extention

All without having to go through each individual cell and actually placing a comma in them all?
I had hoped that saving a file as csv in excel would some how make things know that each cell has an implied comma in it... if that makes sense.

Trenloe
March 26th, 2018, 20:40
I had hoped that saving a file as csv in excel would some how make things know that each cell has an implied comma in it... if that makes sense.
Saving a spreadsheet as CSV will put a comma between the data contained in each cell.

DM Patrick
March 27th, 2018, 02:32
Saving a spreadsheet as CSV will put a comma between the data contained in each cell.

I must be doing something wrong, then. I entered the data into Excel, saved as CSV, then re-copied the data to the clipboard and tried to import but it came out wonky.

Trenloe
March 27th, 2018, 02:34
I must be doing something wrong, then. I entered the data into Excel, saved as CSV, then re-copied the data to the clipboard and tried to import but it came out wonky.
Did you open the CSV file in a text editor and copy from there? Copying from within Excel, even if the file type is CSV, still contains Excel control codes.

DM Patrick
March 27th, 2018, 02:40
I did not. That's where NPP or Word come in. Thanks. I had resorted to using a formula I found

=[cell]&","

I'm starting my first programming class next session - C++, hopefully I'll learn me some stuff soon.

Varsuuk
March 27th, 2018, 17:34
This forum needs a “bookmark” or favorites button... or does it have one but I am clueless?

Both sound really helpful!

Andraax
March 27th, 2018, 18:36
"Thread Tools -> Subscribe to Thread". Top right of each page.

Varsuuk
March 27th, 2018, 19:17
If (isThereWayToMarkThreads)
{
varsuuk.observationalSkills(eCLUELESS);
}

Now we are all clear, thank you.

jrh18
March 28th, 2018, 02:27
I would recommend a change to the instructions that tells the user to copy the content of the CSV file from a text editor. I personally have Excel on my computer and that is the default for opening CSV files. Copying selected cells from the Excel interface creates a much different result than copying text separated by commas. Same is true for Google spreadsheets.

Knowing this now it is an highly useful extension and just saved me a bunch of time taking data from my google spreadsheet and putting it into FG. It also means that i can feel confident is creating tables quickly in Google sheets and then can paste them into FG where I will read them.

rob2e
June 23rd, 2018, 02:32
This apparently does NOT work within CLASS FEATURE entries. I was dismayed.

rob2e
June 26th, 2018, 00:02
I can't seem to get this to work within ITEM descriptions. Works in STORY so I know I'm doing it right.

Zacchaeus
June 26th, 2018, 00:16
Items don’t accept formatted text, so that would be the reason for that. Magic items on the other hand do accept formatted text.

I don’t think class traits or features accept formatted text either, but class descriptions do.

rob2e
June 26th, 2018, 00:55
Items don’t accept formatted text, so that would be the reason for that. Magic items on the other hand do accept formatted text.

I don’t think class traits or features accept formatted text either, but class descriptions do.

I guess I'll wishlist those.

ProNobis
November 1st, 2018, 16:49
25157
Hey Rob, just thought I would let you know that Items and Class Features do take rich text. the attached image shows sister elements to table (heading, list, linklist) that I've used in those locations for the past 12 months. I tested the ctrl + 6 command and a table was easily inserted at both locations. Therefore, the features do work in FG. I'm working on a different project right now, but might take a look at why it is not working there later. If I had to guess, the extension probably does not declare those window classes when it declares where to look for #table# . If that guess is correct, I should be able to fix it myself, but that would mean de-compiling his extension (which I would view as an ethical breach to do without his permission). Lokiare1 may I take a look and see if I can fix it (I would plan on just re-posting it to this thread)? Thank you!

rob2e
November 1st, 2018, 20:47
25157
Hey Rob, just thought I would let you know that Items and Class Features do take rich text. the attached image shows sister elements to table (heading, list, linklist) that I've used in those locations for the past 12 months. I tested the ctrl + 6 command and a table was easily inserted at both locations. Therefore, the features do work in FG. I'm working on a different project right now, but might take a look at why it is not working there later. If I had to guess, the extension probably does not declare those window classes when it declares where to look for #table# . If that guess is correct, I should be able to fix it myself, but that would mean de-compiling his extension (which I would view as an ethical breach to do without his permission). Lokiare1 may I take a look and see if I can fix it (I would plan on just re-posting it to this thread)? Thank you!

I see no image?

Edit: and now i do... lol

lokiare
November 2nd, 2018, 15:38
You can take a look and see. The way it works is it takes the last window that was opened and the last formattedtext field and enters the table there.

ProNobis
November 2nd, 2018, 23:45
Thank you Iokiare1!

Yes your code searches for type =="formattedtextfield" however it only does that within w.getClass ()= "encounter" (ie story modules) and automatically populates within w.getClass () = "table" (rollable tables)

You will note that if you add a section nearlly identical to the encounters that instead says reference_feat your extension will now work in feats.
if w.getClass() == "reference_feat" then
for k,v in pairs (w.getControls()) do
dMessage(type(v));
if type(v) == "formattedtextcontrol" then
cLastFormattedText = v;
cLastRollTable = nil;
elseif type(v) == "formattedtextfield" then
cLastFormattedText = v;
cLastRollTable = nil;
end
end
Your lua is perfect for this and needs no expansion.

I think that it would probably be pretty easy to expand to work in a bunch of other locations that have rich text, unfortunately they have a slightly different setup and will require different lua (which I'm still awful at as I've only worked XML, XSD, and C++). A quick search of the rulesets for "ft_columnh" should help you find many of the other sections for rich text (Adventure logs, class descriptions, items, item templates, powers (spells), equipment, magic items (the magic item forge?), and quests) Not sure where the class features are hiding... if you want I can try to dig that up for you. Do you want me to try to learn enough lua to expand your extension to handle all of this, or is this enough of a hint for you to finish it up on your own?

P.S. If I've shown too much of your code here, let me know and I'll take it down. I figured it would help with explaining and came from an extension with no DRM so it would be okay, but if I'm wrong please let me know.

lokiare
November 13th, 2018, 15:17
Thank you Iokiare1!

Yes your code searches for type =="formattedtextfield" however it only does that within w.getClass ()= "encounter" (ie story modules) and automatically populates within w.getClass () = "table" (rollable tables)

You will note that if you add a section nearlly identical to the encounters that instead says reference_feat your extension will now work in feats.
if w.getClass() == "reference_feat" then
for k,v in pairs (w.getControls()) do
dMessage(type(v));
if type(v) == "formattedtextcontrol" then
cLastFormattedText = v;
cLastRollTable = nil;
elseif type(v) == "formattedtextfield" then
cLastFormattedText = v;
cLastRollTable = nil;
end
end
Your lua is perfect for this and needs no expansion.

I think that it would probably be pretty easy to expand to work in a bunch of other locations that have rich text, unfortunately they have a slightly different setup and will require different lua (which I'm still awful at as I've only worked XML, XSD, and C++). A quick search of the rulesets for "ft_columnh" should help you find many of the other sections for rich text (Adventure logs, class descriptions, items, item templates, powers (spells), equipment, magic items (the magic item forge?), and quests) Not sure where the class features are hiding... if you want I can try to dig that up for you. Do you want me to try to learn enough lua to expand your extension to handle all of this, or is this enough of a hint for you to finish it up on your own?

P.S. If I've shown too much of your code here, let me know and I'll take it down. I figured it would help with explaining and came from an extension with no DRM so it would be okay, but if I'm wrong please let me know.

Unfortunately I don't have time to update it, but feel free to update your copy. You might even be able to iterate through each sub-window (control) looking for a formatted text field/control which would make it more universal all around.

ProNobis
November 14th, 2018, 15:11
We will see if I have time. I'm starting to work on a different GUI that would allow input of data into FG (as well as PDF, e-book, and the other 3 VTTs)... so odds are that that is where my time will be going.

mattekure
July 14th, 2019, 15:20
I have written an update to this extension that is based on and uses some of its code with permission. I posted it to another thread https://www.fantasygrounds.com/forums/showthread.php?49930-CSV-Table-Importer-MK

The new extension should now work in every formatted text field in CoreRPG, 5e, 2e, PFRPG, PFRPG2, and SavageWorlds. I have also rewritten the CSV importing and parsing to fix some minor bugs there. It now supports quoted CSV values that contain commas in them.