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

Allowing Overwriting #4

Open
mutton44 opened this issue Jul 21, 2022 · 4 comments
Open

Allowing Overwriting #4

mutton44 opened this issue Jul 21, 2022 · 4 comments

Comments

@mutton44
Copy link

Hi,
I've got two questions/feature requests for you to consider

  • Is it possible to add a toggle to allow overwriting an exported file?
  • Could the export use the Note Title as the exported filename?

Cheers

@metawops
Copy link
Owner

Hi, I've got two questions/feature requests for you to consider

  • Is it possible to add a toggle to allow overwriting an exported file?
  • Could the export use the Note Title as the exported filename?

Cheers

Thank you, M, for taking the time and writing those suggestions. And for using my plugin! 😊

Those are interesting suggestions! I'm curious: can you tell me more about the first idea? Why would you need that? Is the current implementation of how files are saved not working for you? Why? I just want to understand the real motivation behind your request. 😉

The second idea is great! Do you think a switch for either exporting with the note title or exporting with the current behaviour would be useful? Or maybe the current method isn't useful at all?
What should happen if you opted for saving under the note's filename and you already did that and the file <note title>.csv already exists? Should it be overwritten? Without warning? Or should the plugin silently create a 2nd file with an increasing number added at the end of the base filename? Or should the plugin ask for another filename?

So much to consider ... What are your thoughts? What would help you the most?

@mutton44
Copy link
Author

Thankyou for taking the time to create the plugin! 😄
Okay, the much needed background. I would like to import the csv into Excel as a data source. The filename changing makes this a tad awkward (having to manually rename). If the file name remains the same, Excel can refresh the data. So, if your plugin could overwrite the file this should just work. Having the Note Title as the exported file name would be icing on the cake from a human readable point of view.

Having the option to toggle between what is currently implemented or the Note Title , I think, would cover some scenarios. Saying that, If exporting multiple tables, using just the note title may be better. In my opinion.
On the numbering side of things, whilst it isn't useful for my current use case, I think once again having the option to toggle numbering on/off could be useful.

Not knowing how others use the plugin I can't comment on whether my ideas here would break things for others!

I've been looking through your plugin and experimenting. For the record I am a total noob with coding....
I changed the const filename to:
const filename = this.app.workspace.getActiveFile().basename + '.csv';
This gives desired output for the initial file name. But I don't know if its technically the correct way of achieving it.

With regards to overwriting an existing file. My thoughts on process were:

  • If <NoteTitle>.csv exists
  • Delete <NoteTitle>.csv (with a prompt)
  • Write new <NoteTitle>.csv

Alternatively, instead of deleting the file it could be

  • rename <NoteTitle>.csv and append file name with numbers ie<NoteTitle>-001.csv
  • Write new <NoteTitle>.csv

This would give some file history to the exports in case of issues, and also leave the latest one with the same name for importing elsewhere. This may negate the need for numbering the files initially or even the option for turning numbering on/off.
I am beyond my limits for actually coding this functionality, so I don't know if this helps, but, I have been trying to understand how/whether these are useful:
this.app.vault.filemap
this.app.fileManager.promptForFileDeletion
this.app.fileManager.renameFile
I must admit much confusion at this point... We are a way off a PR 🤣

I appreciate your time to consider these options!

@metawops
Copy link
Owner

Those are excellent thoughts & suggestions, M, and I'll look into all this. But don't expect any updates soon because I'm unfortunately a bit short on time for this hobby. 😞
But I totally hear you and I'll work on it.

@mutton44
Copy link
Author

mutton44 commented Jul 29, 2022

It's your plugin, do as you wish in the time you want 😄. I still appreciate its existence!!
I understand the spare time for hobbies thing. Need a clone haha.

Just for reference for anyone else playing with this. The Dataview Count screws up consistency for the first column name.
The counter can be removed (globally) using the following css snippet - thanks Obsidian discord!

/* hide file count in dataview tables */
.table-view-table tr:first-of-type th:first-of-type > span.small-text {
    visibility: hidden;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants