Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Export and then re-import CSV data? (Read 1286 times)
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Export and then re-import CSV data?
Feb 19th, 2016, 9:17am
 
I know it is possible to export data from Tinderbox in CSV format for manipulation in spreadsheet programs or others. Is it possible to then re-import that data into the original notes?

E.g.,

I have notes:

F100
F101
F102

I export these notes along with one or two attributes to a CSV file. I then add a column to that file. I make a new attribute in the Tinderbox file corresponding with that column name. If I copy/paste this CSV data back into Tinderbox, is there a way to "merge" this data back to the original notes? The name attribute will be the same, but the other columns (including the new column) will be new ...
Back to top
 
 
  IP Logged
J Fallows
Full Member
*
Offline



Posts: 418

Re: Export and then re-import CSV data?
Reply #1 - Feb 19th, 2016, 10:40am
 
I haven't re-run this to be sure, but based on my experience it seems it should work. I've frequently done things fairly comparable and it has worked the way you hope. Good luck!
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export and then re-import CSV data?
Reply #2 - Feb 19th, 2016, 10:47am
 
No, This is something I've often wanted - but I can see there are lots of edge cases that would make this used-by-a-few feature require some work to implement. An obvious case is multiple notes with the same note - the app can't just trust to user is diligent enough to avoid this, etc. But, on a more positive note, I think there is a work around…

Let's assume all the 'merge-to' note are in or descended from a current container. Let's call that 'X'. We import our data into another container. We'll call that 'Y', but it doesn't really matter as long as it isn't in/under 'X'. Now we can make a stamp, for instance (tested in v6.4.0):

$MyString("/Y/"+$Name) = $MyString
$MyString("/X/"+$Name) = $MyString

Using this on a note inside 'Y', the note of the same name in 'X' now gets a new $MyString. Depending on the data type, you will replace or append (Set type) existing data.  For List-type you may need to use an interim list.intersect() to get the common values  from both sources before replacing with the new list.

I used a stamp for my test rather than an agent for my test but I'd assume the latter would work as well. Probably a got idea to test first with a stamp before letting rip with an agent. So, there's some manual configuration of the path to the existing target note for the merge. If notes are unique but all over the doc, consider using a find() - though note find() results require explicit re-duping for aliases.

Lastly, once data is merged, don't forget to remove the imported data notes - especially if you don't want dupe note names. If you want some element of roll-back you can always save a copy of the doc before deleting the CSV import notes. Plus, you've OSX file versioning, Time Machine, etc.

I hope that helps, even if it is a 'roll-your-own' type of solution.

Edit: corrected code to reflect preceding description (as prompted by @derek's reply)
Back to top
 
« Last Edit: Feb 19th, 2016, 5:38pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export and then re-import CSV data?
Reply #3 - Feb 19th, 2016, 10:50am
 
Seeing @JF's reply (while I was testing mine), maybe I'm mis-remembering and TB will automatch/merge if it finds an existing note. Should that be the case, I'd assume that if it is also the case that the recieving TBX has >1 matching note then the merged note will be the first match by $OutlineOrder.

My recollection is that TB doesn't do this, in which case my answer above applies.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
J Fallows
Full Member
*
Offline



Posts: 418

Re: Export and then re-import CSV data?
Reply #4 - Feb 19th, 2016, 11:04am
 
On re-reading the original question, and Mark A's responses, I see that I was mis-understanding what you are trying to do. What I've done is simpler and less ambitious. As a general proposition, and also in this specific case, Mark A has the more authoritative view!
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Export and then re-import CSV data?
Reply #5 - Feb 19th, 2016, 11:56am
 
For lots of cases, this is possible and straightforward.  For various edge cases, this is a headache. Much depends on exactly what you need to export, how frequently you need to do the round trip, and whether your workflow can tolerate hand-tuning exceptions.

At one extreme, we might have a container with some notes F100, F101, etc. Everything important about these notes is described in a set of user attributes -- numbers, dates, and one-word strings. Exporting these is fairly easy, reimporting them is easy, and now we simply replace the old container with our new container and we're all set.

At another extreme, James Fallows had a spreadsheet a while back with lots of data extracted from thousands of emails. The import was challenging because the data were dirty -- there were unmatched quotation marks, unescaped control characters, and all sorts of nightmares for the parser. So this was a challenge, but it only needed to be faced once; a few hours of finding problem spots and either (a) fixing the data or (b) fixing Tinderbox and all was well. But that would have been a very different sort of challenge if there were going to be a thousand new emails to process every morning.

Back to top
 
 
WWW   IP Logged
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Re: Export and then re-import CSV data?
Reply #6 - Feb 19th, 2016, 5:16pm
 
Thanks everyone. Mark A's solution seems like it will work for me. As for Mark B's caution, I think I will only be doing this rarely and with data without those problematic characters.

FYI Mark A: i had to change the code in your example:

If Original Container is "X"
and Imported container is "Y",

Then this stamp was applied to notes in container "Y" to change the values of notes in the original container "X":

$MyString("/X/"+$Name) = $MyString
Back to top
 
« Last Edit: Feb 19th, 2016, 5:16pm by Derek Van Ittersum »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Export and then re-import CSV data?
Reply #7 - Feb 19th, 2016, 5:37pm
 
@Derek. Ah, yes, I think I reversed my containers durring the test. The takeaway point is that by using offset references, you can copy/merge the the contents of one note's attributes to those of a note of the same name in a different container.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print