Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export data as CSV #96

Open
2 of 5 tasks
brrd opened this issue Dec 15, 2017 · 24 comments
Open
2 of 5 tasks

Export data as CSV #96

brrd opened this issue Dec 15, 2017 · 24 comments

Comments

@brrd
Copy link

brrd commented Dec 15, 2017

Is it a bug or a feature request?

  • It's a bug.
  • I'm requesting a new feature.

Which version are you using?

  • macOS
  • Windows
  • Linux

Which is the version/distribution of the OS?

Win10 64 bits

Describe your issue

First of all, thank for this very promising app.

IMO adding a way to export invoices data in a human-readable format (such as CSV) would make the app more reliable for users, who don't want to loose their data if the app is discontinued one day.

Adding a way to perform this export automatically (each time an invoice is saved, for example), or with a command which could be included in a cron job, would be even better, since it would allow to backup data periodically.

@hql287
Copy link
Owner

hql287 commented Dec 15, 2017

This is a great idea! Thanks!

@mathieudutour
Copy link
Contributor

mathieudutour commented Dec 15, 2017

yeah, while I really like having control of my data, it would be nice to be able to sync the invoices through dropbox or similar (hence the need for an export format)

relevant: https://twitter.com/levelsio/status/940548460847144960

@AlphaStyle
Copy link
Contributor

Im new to contributing and have never worked with Electron before so please be gentle 😄

I tried to look into this, using pouchdb-replication-stream and node-memorystream to convert the PouchDB to JSON in memory before writing to a file (Export / backup).

Im using dialog.showOpenDialog(...) and dialog.showSaveDialog(...) for opening and saving files.

There are two pouchDB's (contacts and invoices) and I think it is more user friendly if we merge these into one export file rather than two so I merge both into one JSON object in memory before I use csvjson to convert JSON to CSV and write it to a file. (This is working so far)

The Problem occured when I want to import this exported CSV file because I must first convert it to JSON. When using csvjson the input JSON and output JSON are not the same 😞

So the question: Do you know of any JSON to CSV - CSV to JSON packages? or should we write our own script?

@hql287
Copy link
Owner

hql287 commented Jan 4, 2018

@AlphaStyle Hey, sorry for the delayed response. Any updates on this so far?

@AlphaStyle
Copy link
Contributor

I have to admit I haven't done much since last time I wrote.
I was hoping someone could provide me with this magical package that will fix my JSON->CSV | CSV->JSON issues.

As of right now I can export everything to one single CSV file. (The import logic is there, just not working cause of CSV->JSON is not correct).

I guess I could try and write my own CSV-JSON converter, but I'm not the most experienced coder 😄 But could be good practice though 👍

@hql287
Copy link
Owner

hql287 commented Jan 4, 2018

So JSON to CSV is fine but you need some help with CSV to JSON?

@hql287
Copy link
Owner

hql287 commented Jan 4, 2018

I guess I could try and write my own CSV-JSON converter, but I'm not the most experienced coder 😄 But could be good practice though 👍

Definitely a good exercise, and you'll help lots of other fellow developers with it 👍

@AlphaStyle
Copy link
Contributor

Yes, CSV to JSON. The PouchDB JSON dump is what I think people refer to as complex nested object with arrays. So csvjson package does something wrong when it covert CSV to JSON.

Maybe I could try and contribute to csvjson instead of starting from scratch.

@brrd
Copy link
Author

brrd commented Jan 4, 2018

@AlphaStyle What about https://www.npmjs.com/package/csv-to-pouch module?

@hql287
Copy link
Owner

hql287 commented Jan 4, 2018

But you'll only need CSV to JSON for importing data, correct? If yes, how about making this 2 separated PRs, one for export, one for import. I can use the export module for #124

@AlphaStyle
Copy link
Contributor

Unfortunately csv-to-pouch won't work for my approach because Manta uses two PouchDB's (Invoices and Contacts) and csv-to-pouch does not return the JSON, only add it directly to PouchDB (please correct me if I am wrong).

I am hoping we can continue to have only one exported CSV file to maintain the simplicity for the end-user.

Maybe I should provide more information / pictures of my issue so people can know exactly what I am strugling with 😄

I might have it all wrong though, maybe I am over thinking it. PouchDB dump, here you can see an example of the JSON I get from PouchDB dump. In theory all I need is the docs objects because they are the ones with the important content, but as of right now I save EVERYTHING.

@AlphaStyle
Copy link
Contributor

@hql287 Ok, let me just double check it works and then I will PR it :)

@mathieudutour
Copy link
Contributor

oh dumping the entire pouchdb probably won't work: a csv is more or less an array of JSON objects.

So what you really want is only the docs. We don't really about all the metadata (I would even remove the _rev from the docs).

Then the csvjson will probably work

@hql287
Copy link
Owner

hql287 commented Jan 4, 2018

So what you really want is only the docs

👍 This is what I would do, too.

@AlphaStyle
Copy link
Contributor

Im only storing the docs now. Still not working the way I want it :/
I updated everything to fit in with the recent changes since last time I developed.

Do I need permission to make a pull request or am I doing something realy wrong?

@mathieudutour
Copy link
Contributor

if you have a fork, no.

What does your JSON look like?

@AlphaStyle
Copy link
Contributor

I really wanna do a pull request so you guys can see for yourself 😄

ERROR: Permission to hql287/Manta.git denied to Alphastyle.
Please make sure you have the correct access rights and the repository exists

I have never experienced this 😞

@hql287
Copy link
Owner

hql287 commented Jan 5, 2018

I have never experienced this 😞

Well, then you're in luck today, haha.

Kidding aside, here's how you would do it:

  • Create a fork of this repo
  • Work on the PR locally on your machine
  • Back to this repo home page and create a new PR
  • Click on the compare across forks
    compare across forks
  • The base fork should be this repo dev branch and the head fork should be the PR branch on your fork.
  • GitHub will diff the 2 branches and let you know if it's possible to create the PR

@hql287
Copy link
Owner

hql287 commented Jan 5, 2018

I have never experienced this 😞

Don't worry, we all start somewhere.
GitHub also has a detailed guide on how to create a PR from a fork.

@AlphaStyle
Copy link
Contributor

I am sorry for super late reply!
I do appreciate your patient and wisdom 😄

I did not know about the fork approach. I will read the guide and make a PR 😄

@ghost
Copy link

ghost commented Mar 1, 2018

I think @mathieudutour has a point. CSV is ok for human readability, and its fine to export it with a click on a button. But additionally some realtime json export to a folder set in the settings of the app, would be what i'm more interested in. So that you can watch the folder for filechanges with whatever syncing tool you'r using :)

And automatically importing/syning the files on app start, if they exist.

Opinions?

@hql287
Copy link
Owner

hql287 commented Mar 2, 2018

But additionally some realtime json export to a folder set in the settings of the app, would be what i'm more interested in. So that you can watch the folder for filechanges with whatever syncing tool you'r using :)

Sounds interesting. One of the reasons that I chose pouchDB was because of its ability to sync with a remote server. But this should be a separate feature and deserve its own PR.

@AlphaStyle has already been working on this for some time. You might want to take a look here: #143.

@ghost
Copy link

ghost commented Mar 2, 2018

But this should be a separate feature and deserve its own PR.

Absolutely! Just wanted some feedback before starting a new feature request :)

@hql287
Copy link
Owner

hql287 commented Mar 2, 2018

Sure, will get back to this after I'm done with releasing a v1.1.3

@hql287 hql287 added this to the Build 07 - v1.1.5 milestone Mar 10, 2018
@hql287 hql287 removed this from the Build 07 - v1.1.5 milestone Aug 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants