AttributeError #5
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
more info required
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
yulqen/datamaps#5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The following command
dm.exe export master [file path to master]got this error.Have sent you the files. Cheers.
Can you also email me the config file - sorry, forgot to ask for that earlier. Ta.
sorry stupid question but I've kind of forgotten where the config file sits now. It's sort of hidden now isn't? Does the user actively use it in Datamaps?
You might be right Will - it's probably a massive documentation fail on my part.
Have a look in something like - anything related to
datamaps- there should be aconfig.inifile somewhere:C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>or
C:\Users\<username>\AppData\Roaming\<AppAuthor>\<AppName>Of if you're doing this on Ubuntu, it may be in:
~/.local/share/datamaps/...Let me know. I suspect if you find it, you might be able to fix your problem. I think the docs for
bcompilerstill apply here - although I'd need to investigate more thoroughly.will@will-ThinkPad-X230:~/.local/share/datamaps-data$ ll total 8 drwxr-xr-x 2 will will 4096 Jan 3 23:18 ./ drwx------ 24 will will 4096 Mar 3 14:37 ../can't seem to find it.
I can vaguely remember that this might be a master wb issue. I seem to remember that it was something to do with how the master spreadsheet was structured, because the error wasn't an issue if you ran it with a master that had been compiled by Datamaps itself. does that ring any bells?
Is it not inside that directory?
What value is at cell
A1in your master? It is expecting something that resembles a file name - i.e. something.xlsx.definitely something to do with the master being used. I ran a
datamaps export master [file path to master]using a master document that was built by datamaps, that worked fine. Will send you that dm.cvs and master file. I thought it might be something to do with blank columns or blank rows, but deleting columns/rows doesn't seem to make difference.I've not had a chance to look at this in detail, nor check the files you sent, but I think the reason this is happening is because you are giving the header cell a "non-file name" entry.
When you use
datamaps importthe program rather dumbly gives the "title" of each column of data the filename of the source - e.g. "Big Roads Project.xlsm", because it does not make any assumptions about the proper title for the project at that stage. This is reflected when you wish to recreate the file upon export, so when you rundatamaps export master [etc]the program finds the name of the intended destination file in that cell.This is why it works when you use a master created by datamaps but crashes when you create your own master. To get it to work in the interim, you need to ensure the destination file name for the export is included in the cell, e.g.
big_roads_project.xlsm, for example.Thanks for your patience in picking this up (again!) - I will fix it so that this no longer happens. Are you happy for the program to create an exported file such that
Big Important Roads ProjectbecomesBig_Important_Road_Project.xlsm? This might have implications for the complexity of project titles (for exampleBig Important Road Project - Stage 2 - 2021/24might need a bit of imaginative parsing to create a useable file name, bearing in mind you can't have forward slashes, dots etc in Windows file names), but I can write some stuff to handle this and make it as simple as possible.Let me know what you think.
Hi Matt have tested this and it doesn't seem to be the issue. couldn't get it to work when inserting .xlsm at end of file name. Plus the master that Datamaps compiled doesn't have .xlsm at the end of the file name. 😞
Ok - will have to look at this on the train up tonight. Did you find at config file in the end?
Thanks. Sorry about this.
Apologies are all mine Mr Grant!
@banillie - did you email me the blank_template.xlsm file?? Can only find an email from yesterday ("other test docs") that contains datamap and master file. I may have missed the email. I can probably use an old template, probably...
Am running this with datamaps v1.0.1 using the master and datamap (but with an old template, which I don't think matters) you sent and getting no error.
Is there a value in cell B1 of the master you're running? The exception is clearly saying that it is finding no value there and I'm not sure why. Email me in a new email if you don't want to include the value on the publicly available thread (which is a good idea).
Hi Matt I sent you two emails via egress yesterday the first batch included the blank template as well as the master that was raising an error. Did you receive it?
The second batch worked, which is why you’re not getting an error.
No - only got one email with master and datamap.
M
--
Matthew Lemon
matt@matthewlemon.com
On Wed, 4 Mar 2020, at 4:38 PM, Will Grant wrote:
ok have tried sending again, should reach you soon.
@hammerheadlemon did you receive the email I sent yesterday ok?
I did @banillie but I've not had a chance to look at it yet. The first attempt might been blocked due to it containing a zip a file. Anyway - I've got it and will look at it when I get a chance later today. Sorry not had time yet!
Can reproduce the error - great. Will dig in later to fix. There's an issue with what openpyxl considers to be the far boundary of the spreadsheet data. Will fix and come back to you very soon.
Thanks. Makes sense. I thought that might be the issue and tried deleting columns, but obviously not enough. Just tested moving all data into a new/blank wb and that worked fine.
When reading the sheet data at
openpyxl.worksheet._reader.WorksheetReader.bind_cells,WorksheetReader.parser.parse()is creating a listrowwhose values aredicts. In the error master file, starting atidx7 (row 7 in the sheet),parse()is finding aNonevalue in in row 7 col 18 (col R). There is no visible value in the spreadsheet at this point - there may be a value internally here, but it is being read asNone. Regardless, openpyxl is therefore considering col 18 as within the boundary and therefore later when datamaps processes the data extracted from the master is encounteringNonevalues - in our problematic case, starting at cell H1.If you type a value in the spreadsheet at R7, the text is formatted as light blue, and subsequent entries down the rows appear in different colours. Similarly with next door cells.
This could be fixed by handling the AttributeError but this complicated by the fact that there are valid
Nonevalues to be found within the file. The other option is to require the user to specify (using an optional command-line argument) the max column width of the master spreadsheet so that such overruns do not happen. This would provide safety, but obviously changes the UI.Will investigate further.
clearly something strange happening in the background. just to note the master file (which isn't working) was built from a program I developed to compile a master for commission. that code is here.
github.com/banillie/analysis_engine@325f1840e9/data_mgmt/DfT_commission_data.py (L282)yes I can see how this is a tricky one from a user perspective. presumably the only row of interest in relation to this is row 1. So if Datamaps hits a blank cell there it can assume that this is a stop and start transferring data to templates?
An issue with this would be that if there's a blank column, which is then followed by some columns with data in them, that data would not get transferred. However, this issue could be easily fixed by the user.
You're right - row 1 is the key, so we could just catch the exception there.
Basically, we can make things a bit more robust in the code and improve documentation to warn the user of the limitations.
Thanks for ref to your code - I'll have a look. Interested to find out what's going on.
In terms of urgency, have you run the export to hit your goal at work?? Did you manage to do it using a clean master file??
yeap we have been able to run the export by moving all the data over to another wb... so that work around solves this issue for us, and no urgency from our point of view.
Thanks for looking into this Matt.
Fixed in
d030d2d2d5.datamaps.exev1.0.3 available at Twenty Four Software; released on PyPI as v1.0.3 (usepip install -U datamapson your system to get the new version).exportfunction now recognises if it hits aNonevalue in the top cell of a master column and assumes there has been an issue with the datamap, and is trying incorrectly to export data beyond a sensible column boundary. It gives the user a warning in the console log that this has happened but this message may be pushed out of the screen quickly by subsequent warnings such as missing datamap entries - scroll up in the console buffer to view.Please report further problems.
Great! We’ll test it pronto. What service!
Best, Will.
@hammerheadlemon just ran a test on datamaps 1.0.3 and it didn't pass unfortunately. I got this error. Sorry!
Ah, ok. Thanks for taking the time to let me know, and apologies.
Using the same files/command? Are you using PyPI datamaps or datamaps.exe downloaded from the site?
The PyPI one. Should I test the datamaps.exe version as well? Cheers Matt.
No, it's fine. Presume it's exactly the same test files, etc. I'll take a look.
I know - stupid me... Can you please test it with 26 cols or less - i.e. no data beyond col Z, and let me know.
Ok tested and it worked if there was only data in it up until column Y, so 25 cols. does that make sense? Thanks Matt.
Yeah, it does. Thanks for confirming. I implemented the fix without testing scenarios whereby there are over 26 columns. I will work on the fix and post here with an update. Thanks for your patience as ever! Hope you and your family are staying safe and well.
From: Will Grant notifications@github.com
Sent: 17 March 2020 16:00
To: hammerheadlemon/datamaps datamaps@noreply.github.com
Cc: Lemon matt@matthewlemon.com; State change state_change@noreply.github.com
Subject: Re: [hammerheadlemon/datamaps] AttributeError (#5)
Ok tested and it worked if there was only data in it up until column Y, so 25 cols. does that make sense? Thanks Matt.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub https://github.com/hammerheadlemon/datamaps/issues/5#issuecomment-600151497 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB4ISJO2QN7AXJTMSQMZS3RH6NAVANCNFSM4LALAKYA . https://github.com/notifications/beacon/AAB4ISOXXW3AZ4TWUVSYBYLRH6NAVA5CNFSM4LALAKYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEPCZLSI.gif
yes were all good thanks, although decided to take Arthur out of school. Same for you and your family.
Cheers, Will.
@banillie - I do have it on my list to fix and close this issue before you do your next export run.
Thanks Matt. That would be great. 👍
At some point, it would be great if you could test the fix, @banillie:
In your Ubuntu terminal, do the following:
python3 -m venv /tmp/datamaps-tmp-virtualenv(assumingpython3is your system python 3. If not, just dopython -m venv /tmp/datamaps-tmp-virtualenvhere)source /tmp/datamaps-tmp-virtualenv/bin/activatepip install datamapspip list- check that you havebcompiler-engineversion1.0.3pip uninstall bcompiler-enginepip install git+https://github.com/hammerheadlemon/bcompiler-enginepip list- make sure you havebcompiler-engineversion1.0.4, not1.0.3Use the test files you sent me, or at least a master that has data in cells beyond the end row expected - the test master you sent me had text in cells around row 3000; also ensure there is text in cells beyond the end column - so way after the last column of project data.
datamapsshould be able to accommodate this now. It will throw out aWARNINGlog message for every project/column, which I have an issue to fix to make it slightly more user-friendly, but it should not throw andAttributeError. To test:datamaps export master <path-to-master>whilst you have this test virtualenv activated.When you are finished testing, get rid of the test virtualenv:
deactivaterm -r /tmp/datamaps-tmp-virtualenvReport back here. Once we're happy, I will build the executable for your guys to work with.
@hammerheadlemon ok will get onto this asap. might be over the weekend. Cheers, Matt.
Hi Matt,
Tested and worked very well. 🙌 💯
It came up with a nice message to highlight that there were extra cells in the master that the user might to check. However, the export continued and completed nicely with no issues.
Two things to note:
I got the below error message when (pip) installing datamaps. That message came up in red. When I did pip list it still showed openpyxl being installed though.
Failed building wheel for openpyxlThe other thing was that when opening each output file/project returns in libreoffice I got a message saying number of the columns, in the that file, was exceeded. This generates a warning message, but the wb opens ok. I don't remember having this message before. When I send them over to the work computer they open in excel fine without an error message though. One last thing I need to check with Joe on Monday is that the macros built into the project returns runs ok. Do you want me to send you some of the output files so you can have a look also.
Once again, thank you for all this.
Best, Will.
Thanks for doing this Will - really appreciate it. I'm going to do a little bit more tidying on this version before I release it (including better log messaging when the long long
exportprocess is running - right now it's a black hole -, so I might need you to do the same again very quickly early next week if you can.I think the
pipmessage can be fixed by doing apip install wheelin your virtualenv or doingpip install datamaps --no-cache-dir, although I'm not 100%. It's not essential for a wheel to be present for everything to work. So not to worry. I see the pip messages all the time too.I've not tested on Libreoffice this time (thanks my current focus on Windows!) but will bear this in mind when I switch testing to Linux.
I'll carry on testing with the files you sent me last week. If you find anything else in the meantime - let me know, and let me have the usual batch of files that are problematic.
Have just sent you a few files via egress, which you might find useful. Look forward to further testing.
Cheers, Will.