Rank: Advanced Member Groups: Registered
Joined: 12/03/2011(UTC) Posts: 101 Location: Chicago
Was thanked: 16 time(s) in 7 post(s)
|
Hi all- I get this odd behavior opening files from either the recent file menu or by double clicking the SMath file in Explorer. SMATH thinks the current directory is C:\Windows\.... and therefore it can not find the files I am trying to read in. Its not consistent, but when it starts happening, I 'fix' it by either: deleting the CurrenDirectory("" and re-writing it, saving the file as the same name or slightly modified file name in the SAME directory, or by signing off or rebooting.
I can not figure out if this is a Windows issue or an SMath issue. And now that I think about it, its almost always a referenced spreadsheet, but that is usually what I am bringing in. I can not figure out what else to attach or debug info might be helpful. I tried searching but couldn't find anything. Dennis Edited by moderator 28 February 2019 12:41:51(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/03/2016(UTC) Posts: 276 Was thanked: 91 time(s) in 57 post(s)
|
I can't speak to why import isn't working... but you can set the root directory of the smath file better with DocumentDirectory(). |
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/03/2016(UTC) Posts: 276 Was thanked: 91 time(s) in 57 post(s)
|
I found in a snippet of mine where I import an excel file, I did something like below. 1. Save document directory location. 2. Change directory location to file I want to import. 3. Import sheets 4. return current directory to document directory. I don't know why I did it like this as I made it years ago, but maybe I ran into a similar issue.
Edited by moderator 28 February 2019 12:42:17(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
If you remove/disable CurrentDirectory() before opening the worksheet, importData.XLSX doesn't works as it should? Edited by user 22 February 2019 09:46:13(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 12/03/2011(UTC) Posts: 101 Location: Chicago
Was thanked: 16 time(s) in 7 post(s)
|
I don't think this is an excel plugin issuse, this is a file handling issue with SMATH.
The reason I am trying to be explicit in the directory and filename is I have the necessary job/project specific reference files in one 'local' directory and the global reference files in another 'network drive' directory location. I am trying to force SMATH to only read and write out to the local directory.
I copy and paste the template files from the network folder to the local job/project folder.
Then when I open the local files, it would read and write back to the network one.
When I try to use the File menu ->Properties it shows the right location.
If there is a better way to enforce file locations, I am all ears.
Dennis
|
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
I think I fixed it ( XlsxImportExport plugin updated). The error occours because you have the excel file open by another process; this was related to a fix introduced with the no more used ClosedXML library. About the directories: - CurrentDirectory() shows a known issue about Environment.CurrentDirectory not updated in SMathStudio while you change worksheets (I'll check it later on SS side);
- DocumentDirectory() rely on Store.FileName, that should works correctly. If you want to build absolute paths, you should use this as root;
- importData.XLSX() rely on Store.FileName too for relative paths, thus either if you use relative paths or you build absolute ones using DocumentDirectory() the result is the same.
- once you pass an absolute path to importData.XLSX() anything else doesn't matter whatever is the behavior of CurrentDirectory() or DocumentDirectory()
Edited by user 23 February 2019 14:22:47(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
2 users thanked Davide Carpi for this useful post.
|
on 23/02/2019(UTC), on 27/02/2019(UTC)
|
|
Rank: Advanced Member Groups: Registered
Joined: 12/03/2011(UTC) Posts: 101 Location: Chicago
Was thanked: 16 time(s) in 7 post(s)
|
Davide- Yes, I probably have that spreadsheet open as I am working. I did not think it was an issue. I will try it with it closed. If I do not explicitly define the filenames, then when I copy the files as templates, SMATH seems to remember the origins and relative paths from the origin. So the 'child' SMath sheet finds the 'parent' SiteData spreadsheet. The referenced include statement, which is obscured in my original post, is pointing back to the 'parent' location of the templates too. Perhaps that is part of the issue? Even if I open it from the File Menu -> Recent Files -> entry, it opens with the wrong CurrentDirectory(). Then when I go to save it, SMath seems to remember the last directory that I was working in. Are these both symptoms of the issues you referenced? Is it the same error reported in the newer thread? See screens below. |
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
Originally Posted by: sinneD Yes, I probably have that spreadsheet open as I am working. I did not think it was an issue. I will try it with it closed. Now it should works even if the file is open, or should give a different error. Originally Posted by: sinneD If I do not explicitly define the filenames, then when I copy the files as templates, SMATH seems to remember the origins and relative paths from the origin. So the 'child' SMath sheet finds the 'parent' SiteData spreadsheet.
The referenced include statement, which is obscured in my original post, is pointing back to the 'parent' location of the templates too. Perhaps that is part of the issue?
Even if I open it from the File Menu - The problem with built-in importData and maybe some plugins is that if you are using relative paths and they rely directly on the framework functions, these are using the "Current Directory" to resolve relative paths. XLSX import/export, DataExchange, WriterRegion, are "aware" of this potential issue and for relative paths they rebuild a rooted path internally. The parent location was pointed because you started your smath session there, then you opened the child in the same session (it is a bug, not your fault). In short actually you might experience issues: - if in the same SMath Studio instance you open different sm worksheets in different locations;
- if under the first circumstance you are using relative paths on built-in importData() or some other function that rely directly on framework filesystem functions;
- if under the first circumstance you are using absolute paths created on the fly in the worksheet with CurrentDirectory()
These are all unrelated with the original issue in this thread "Could not find a part of the path ..." that should be solved and was related to XLSX import/export and Data Exchange plugins only. I'll mark this as solved, for the discussion about the wrong "Current Directory" we can use this other thread. Edited by user 28 February 2019 12:48:54(UTC)
| Reason: marked as Solved |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
2 users thanked Davide Carpi for this useful post.
|
on 28/02/2019(UTC), on 28/02/2019(UTC)
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.