how to deal with CapitalizationError during importing in simpro CSV in brightway2? - brightway

when I import a CSV file I get the following error:
CapitalizationError: Possible errors in upper/lower case letters for some parameters.
'_a3_spruce_yes'' not found; could be '_a3_spruce_yes'
'_a3_osb_thickness'' not found; could be '_a3_osb_thickness'
'_a3_primary_frame'' not found; could be '_a3_primary_frame'
'_a3_pp_density'' not found; could be '_a3_pp_density'......(continue)
and if I look into the csv file it looks like (I took only one input and project parameter as example, they are basically all so, with the A capitalized)
Project Input parameters
_A3_Spruce_yes;0;Undefined;0;0;0;No;(0/1) Choice of spruce
....
Project Calculated parameters
_A3_Douglas_Yes;1-_A3_spruce_yes;Choice of Douglas
...(there also other calculated parameters but always with the same A capitalized)
Any idea on:
-why this prob
-how to fix it

There is an error in the input file. The CapitalizationError is incorrect; rather, there are some references which refer to undefined variables in the input data, e.g. _Wall_Weight is defined in a long formula that includes the variables _A3_OSB, _A3_Plywood, and _A3_PP, but these variables are not themselves defined anywhere. The correct error in this case should be a ParameterError, and can only be solved in the input data (and in the exporting program that allows incomplete references to be exported in the first place).

Related

Excel VBA objsnmp.set strange things

I use the objSNMP.get method in Excel VBA without any problems.
I'd like to use the objSNMP.set method, but unfortunately it's not that easy. According to the website, it should work similarly to get, with the difference that there is one more parameter: the value to be sent.
If I try the official way:
objSNMP.Set ("43.18.1.1.2", OIDValue)
Image1
I get the message "Compile error: Syntax error".
I found another solution that works conditionally. Namely as follows (it can be seen commented out in the picture):
randomVarName = objSNMP.Set("OID", Value)
For example:
temp = objSNMP.Set(".1.3.6.1.4.1.9.9.68.1.2.2.1.2." & PortNum, 21)
In this case, the code runs without error. This is interesting because I haven't found any official information about this anywhere. Somewhere deep in the recesses of the internet, I only found this possible solution some time ago.
If, on the other hand, I do not enter the value directly, but write the name of a variable there (e.g. VLANNum),
temp = objSNMP.Set(".1.3.6.1.4.1.9.9.68.1.2.2.1.2." & PortNum, VLANNum)
I receive an error message. Image2
It doesn't matter if the type of the variable is not declared, string or integer. I also tried several different cell types in Excel, but nothing changed.
The error message is:
Run-time error '-2147467259 (80004005)':
The requested SNMP operation attempted to modify a variable, but
either a syntax or value error occurred.
Based on the above, I cannot insert the value read from the excel table at the end of the "objSNMP.Set" method in such a way that it can send the value. I could only solve the task if I create 4094 different "objSNMP.Set" lines and select what is necessary from among them. Not very efficient.
I have the solution. The value transferred with the variable works in the following form:
objSNMP.Set ".1.3.6.1.2.1.2.2.1.7.9", CInt(x)
Where x is the variable.

Excel-VBA: is there a VBA command that reads it's own line number

My Excel 2016 VBA code has rare occasions of fatal errors (e.g. loss of variable or reference values).
It sends mail/text then.
I'm looking for a way to state in which module and code line the problem occurred.
Is there a VBA command that can read the module name and the line number?
...without hard-coding the module and function/sub name.
You can use Erl as long as you have added line numbers to the code.
My idea of best case scenario for emailing fatal errors:
Save all the user's input in a class variable. In case of error, mail the information to yourself plus the type of the error.
This should be enough to replicate and fix.
Concerning a way to get the module name without hardcoding - there is no such way. But using a hardcoded variable for the name is not that difficult - http://www.cpearson.com/excel/InsertProcedureNames.aspx

Operator || is undefined for the argument type boolean, String

I'm trying to create a Parallel Coordinate graph with a csv file I have. The graph I'm trying to make looks like the image I have drawn here -> DrawnGraph. The issue I am having is that the countries are listed individually on the csv file. I need to create a code that places the countries within their corresponding continents. I attempted the code below but I keep getting "The operator || is undefined for the argument type(s) boolean, String"
I realize that I am typing it wrong but I do not know how to fix it. Help please
if(Country.equals("Aruba")||Country.equals("Argentina")||Country.equals("Bolivia")||Country.equals("Brazil")||Country.equals("Chile")||("Columbia")||Country.equals("Ecuador")||Country.equals("Guyana")||Country.equals("Paraguay")||Country.equals("Peru")||Country.equals("Suriname")||Country.equals("Uruguay")||Country.equals("Venezuela"))
Looks like you're missing an occurrence of Country.equals here:
Country.equals("Chile")||("Columbia")||Country.equals("Ecuador")
Add that in and it ought to work.
By the way, you haven't specified what programming language you're using. You probably should.

automating string and number concatenation

I'm having some trouble automating a matlab script which should prompt the user for the variable they are interested in, as well as the date range they want. I then want the script to concatenate their answers within a naming convention for the file they will ultimately load.
variable=input('please input variable of interest');
% temp
start=input('please state the start date in the form yymmdd: ');
%130418
enddate=input('please state the end date in the form yymmdd: ');
%140418
file=sprintf('%s_dailydata_%d_%d.csv',variable,start,enddate);
%so I thought 'file' would look like: temp_dailydata_130418_140418.csv
vardata=load(file);
the two numbers representing the dates are not causing any issues, but the fact that 'variable' is a string is. I know if I put apostrophes before and after 'temp' when I'm promted, it will work, but I have to assume that the end user won't know to do this. I tried putting curly braces around 'please input your variable..', but that didn't help either. Obviously this approach assumes that the date being requested exists in a filename.
Can anyone offer any advice? Perhaps the sprintf function is not the best option here?
Don't use 'end' as a variable name, it is a reserved name and using it could create conflicts with any function or logic block you're defining.
If you know your input is going to be a string: from the documentation for input()
str = input(prompt,'s')
Returns the entered text as a MATLAB string, without evaluating expressions.
As for knowing whether or not the file exists, that's something you'd have to incorporate some error logic for. Either a try/catch block with your load() call or you could use uigetfile() to get the filename.

How to get the filename and line number of a particular JetBrains.ReSharper.Psi.IDeclaredElement?

I want to write a test framework extension for resharper. The docs for this are here: http://confluence.jetbrains.net/display/ReSharper/Test+Framework+Support
One aspect of this is indicating if a particular piece of code is part of a test. The piece of code is represented as a IDeclaredElement.
Is it possible to get the filename and line number of a piece of code represented by a particular IDeclaredElement?
Following up to the response below:
#Evgeny, thanks for the answer, I wonder if you can clarify one point for me.
Suppose the user has this test open in visual studio: https://github.com/fschwiet/DreamNJasmine/blob/master/NJasmine.Tests/SampleTest.cs
Suppose the user right clicks on line 48, the "player.Resume()" expression.
Will the IDeclaredElement tell me specifically they want to run at line 48? Or is it going to give me a IDeclaredElement corresponding to the entire class, and a filename/line number range for the entire class?
I should play with this myself, but I appreciate tapping into what you already know.
Yes.
The "IDeclaredElement" entity is the code symbol (class, method, variable, etc.). It could be loaded from assembly metadata, it could be declared in source code, it could come from source code implicitly.
You can use
var declarations = declaredElement.GetDeclarations()
to get all AST elements which declares it (this could return multiple declarations for partial class, for example)
Then, for any IDeclaration, you can use
var documentRange = declaration.GetDocumentRange()
if (documentRange.IsValid())
Console.WriteLine ("File: {0} Line:{1}",
DocumentManager.GetInstance(declaration.GetSolution()).GetProjectFile(documentRange.Document).Name,
documentRange.Document.GetCoordsByOffset(documentRange.TextRange.StartOffset).Line
);
By the way, which test framework extension are you developing?
Will the IDeclaredElement tell me specifically they want to run at
line 48?
Once more: IDeclaredElement has no positions in the file. Instead, it's declaration have them.
For every declaration (IDeclaration is a regular AST node) there is range in document which covers it. In my previous example, I used TextRange.StartOffset, though you can use TextRange.EndOffset.
If you need more prcise position in the file, please traverse AST tree, and check the coordinates in the document for specific expression/statement

Resources