at top of python program, a command "import csv" "is not accessed" where to find it - csv

import csv
fails, alert "csv.py" is not accessed
yes, there is no file of that name in my current working directory.
Where can I locate a copy of csv.py to use in my current project.
import urllib.request, urllib.error, urllib.parse #this command works
import obo #this command works because I have obo.py in my directory
import csv # csv is underlines with white dots, csv is not accessed
where do I seek csv.ph?
running windows Visual Studio version 1.73.1

Newbie error. The warning from Visual Studio only meant that I imported a module but didn't use it in the program.

Related

Converting python script to exe. Failed to execute script

I have made a game using pygame and now want to convert the script to an exe file. However, when doing this and starting the exe file I get an error saying "Failed to execute script (main.py)". I have tried everything from youtube videos to reading similar questions on Stack Overflow. But nothing works, I get the same error every time. How can I solve this?
Does it have to do something with my imports?
The import that I use in my script:
pygame
random
winsound
mixer (from pygame)
Avoid all of these problems and use PyInstaller (link to related question):
Download this library with pip by typing in the Command Prompt:
py -m pip install pyinstaller
Then, type cd [path to the file].
Finally, type py -m PyInstaller --onefile [script name].py.
PyInstaller will turn your code into one .exe file, in the folder dist, analyzing the modules you need.
After the installation, you can then delete all the other files, like the folder build for example.
If you need other attached files, like images, put them in the folder where the .exe file has been created.
Anyways, if you type exit() anywhere in your code, PyInstaller will raise an error. Simply import sys and type sys.exit() instead.

How to import CSV to KNIME in command line

I want to import a CSV file to KNIME in command line. When I run a command line like this:
"C:\Program Files\KNIME\knime.exe" c:\temp\foo.csv
A dialog pops up, but the button is grayed, I can't click finish. I'm new to KNIME, just installed it, does KNIME support importing CSV directly? Thanks.
That is not how you can import CSV files. That way you can open KNIME workflows. If you want to override a KNIME workflow's input data and (batch) execute the KNIME workflow, you should use flow variables as input and specify them in the command line: https://www.knime.com/faq#q12
-workflow.variable=my_csv_location,C:/tmp/foo.csv,String
Or something similar.
If you just want to import a CSV file to an existing workflow, just drag it on the editor area and it will add a CSV Reader node with the path set.

Can the Import command be invoked via the Design Automation API?

I'm trying to invoke the AutoCAD Import command via the Design Automation API. This works fine from accoreconsole.exe locally, and while the Design Automation API accepts the Import command without error, it proceeds to the next command without importing anything.
In the excerpt of a Design Automation API output log below I'm invoking the Import command both directly from the generated script file and via SendStringToExecute via my plug-in. In the latter case I've pulled the full local file path.
[10/19/2017 06:20:18] Command: Import
[10/19/2017 06:20:18] Enter import file name: "input.stp"
[10/19/2017 06:20:18] Command: ProcessChamberDrawingCloud
[10/19/2017 06:20:19] Command: (command "Import" "\"T:\\Aces\\Jobs\\f4ba423419294f7eacf0d9fac71e790f\\input.stp\"")
[10/19/2017 06:20:19] Import
[10/19/2017 06:20:19] Enter import file name: "T:\Aces\Jobs\f4ba423419294f7eacf0d9fac71e790f\input.stp"
[10/19/2017 06:20:19] Command: _.quit
The 'IMPORT' command in Forge Design Automation have some problem, it doesn't spawn "AcTranslator.exe" process. we are working on some other alternative, we will keep you posted.
IMPORT is a two step process in AutoCAD
First it will spawn a child process like this AcTranslator.exe -i
"input.stp" -o "output.dwg"
When translation is done, a notification is sent to user in the
AutoCAD UI [Right Most corner of AutoCAD Main Window] when you click
on the notificaton bar, translated entities from output.dwg are merged in to current
drawing.
Currently, we see problem at first step.
edited
We have fixed this problem:
I have answered in another stack over flow post Import-In-Forge
For STEP files, the IMPORT command depends upon the AcTranslators.exe and several atf*.dll files. Does your environment have those files, will be the 1st question? But I'm still checking if there is some other approach.

Cypher Neo4j Couldn't load the external resource

In a Windows environment, I'm trying to load a .csv file with statement:
LOAD CSV WITH HEADERS FROM "file:///E:/Neo4j/customers.csv" AS row
It seems not to work properly and returns:
Couldn't load the external resource at:
file:/E:/Neo4j/Customers.csv
Neo.TransientError.Statement.ExternalResourceFailure
What am I doing wrong? thanks in advance
I was getting this error on Community Edition 3.0.1 on Mac OS X 10.10
It appears that the LOAD CSV file:/// looks for files in a predefined directory. One would think that in the argument that one would give the Cypher statement the full path but that is not the case.
The file:/// - for my situation" meant that neo4j would append the given argument you gave to one that was already predefined and then go look for that combined path
The file:/// pre-defined directory directory did not exist entirely
/Users/User/Documents/Neo4j/default.graphdb/import, in my computers directory structure I was missing the "/import" folder, which was not created at install
To fix on my system, I created an "import" directory, put the file to be read in that directory. I executed the Cypher load statement I ONLY put the name of the file to be read in the file argument i.e.
LOAD CSV file:///data.csv
this worked for me.
It appears to be a security configuration. Here's the original answer I found: https://stackoverflow.com/a/37444571/327004
You can add the following setting in conf/neo4j.conf in order to bypass this :
dbms.security.allow_csv_import_from_file_urls=true
Or change the import directory dbms.directories.import=import
You can find the answer in the file
"C:\Users\Jack\AppData\Roaming\Neo4j Community Edition\neo4j.conf"
(above "dbms.directories.import=import")
For version neo4j-community_windows-x64_3_1_1 you have to comment out this line or you have to create the folder \import (which isn´t created through the installation) and add your file into the folder.
There it´s written that due to security reasons they only allow file load from the \Documents\Neo4j\default.graphdb\import folder
After commenting out on # dbms.directories.import=import , you can execute e.g. from
LOAD CSV FROM "file:///C:/Users/Jack/Documents/products.csv" AS row
In neo4j.conf I didn´t have to add/set
dbms.security.allow_csv_import_from_file_urls=true
On (Arch) Linux + neo4j-community-3.4.0-alpha09, edit $NEO4J_HOME/conf
/neo4j.conf:
uncomment or add: dbms.security.allow_csv_import_from_file_urls=true
comment: #dbms.directories.import=import
Restart neo4j (in terminal: neo4j restart), and reload the Neo4j Browser (http://localhost:7474/browser/) if you are using a web browser as your Neo4j interface/GUI.
Then, you should be able to load a csv from outside your $NEO4J_HOME/... directory
E.g.,
LOAD CSV WITH HEADERS FROM "file:///mnt/Vancouver/Programming/data/metabolism/practice/a.csv" AS ...
where my $NEO4J_HOME/ is /mnt/Vancouver/apps/neo4j/neo4j-community-3.4.0-alpha09/
LOAD CSV WITH HEADERS FROM "file:/mnt/Vancouver/Programming/data/metabolism/practice/a.csv" AS ...
also works, but not
LOAD CSV WITH HEADERS FROM "file://mnt/Vancouver/Programming/data/metabolism/practice/a.csv" AS...
or
LOAD CSV WITH HEADERS FROM "/mnt/Vancouver/Programming/data/metabolism/practice/a.csv" AS...
i.e. use ...file:/... or ...file:///...
It's probably an URL issue, try file:c:/path/to/data.csv
See my blog posts:
http://jexp.de/blog/2014/10/load-cvs-with-success/
http://jexp.de/blog/2014/06/load-csv-into-neo4j-quickly-and-successfully/
For the ubuntu system, I placed the file in /usr/lib/neo4j which helped me solved the issue. On every other location, i tried giving full permissions(777) but the problem remains the same. After going through another stackoverflow post, i realized that the file should be kept in neo4j directory.
In the Neo4j desktop select the database you are using, go to the setting and there you will find the solution... just comment the "dbms.directories.import=import" line
# This setting constrains all LOAD CSV import files to be under the import directory. Remove or comment it out to
# allow files to be loaded from anywhere in the filesystem; this introduces possible security problems. See the
# LOAD CSV section of the manual for details.
dbms.directories.import=import ### COMMENT THIS LINE
For macOS Mojave v 10.14.5
Actually, I had to uncomment dbms.directories.import=import from ~/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-e2dd2a9c-d450-4639-861b-1e7e42b56b31/installation-3.5.5/conf/neo4j.conf and restart the service. Then it worked. All files has to be placed in import directory.
Run command LOAD CSV WITH HEADERS FROM 'FILE:/<yourCSV>.csv' as l return l
I am using the Neo4j Desktop and as others have said, the default graph database has a predefined import location. You can find the location by using the UI. If you put the CSV into the import directory, then you can use the relative path directly from you load csv command
Neo4j version is 3.1.1, OS is win10.
For me, LOAD CSV would read from Neo4j_Database_Location/testDB/import/artists.csv.
At first, I put csv file on the path F:\code\java\helloworld\artists.csv, and my cypher sentence is
LOAD CSV FROM 'file:///F:\\code\\java\\helloworld\\artists.csv' AS line
CREATE(:Artist {name:line[1],year:toInt(line[2])})
Then I get the error message returned as follows:
Couldn't load the external resource at: file:/D:/Neo4j/db/testDB/import/code/java/helloworld/artists.csv
It means neo4j itself concat the file path.
"D:/Neo4j/db/testDB/import/" is the Neo4j database location, and the "code/java/helloworld/artists.csv" is the csv file location.
For example, I install Neo4j on the path D:\Neo4j\Neo4j CE 3.1.1, and database loaction is D:\Neo4j\db. I put the CSV file on the path D:\Neo4j\db\testDB\import\artist.csv. If you don't have the file folder "import" on the path, you should creat it by yourself and put your file in the folder "import".
Then, put your csv file in the path, and input cyper sentence:
LOAD CSV from 'file:///artist.csv' as LINE
CREATE(:Artist {name:line[1],year:toInt(line[2])})
In a word, once you put the CSV file in the right path, the problem can be solved.
Related explaination in the LOAD CSV developer-manal
If dbms.directories.import is set to the default value import, using the above URLs in LOAD CSV would read from /import/myfile.csv and import/myproject/myfile.csv respectively.
If it is set to /data/csv, using the above URLs in LOAD CSV would read from /data/csv/myfile.csv and /data/csv/myproject/myfile.csv respectively.
Set the Property "dbms.directories.import=import"
Create folder 'import' explicitly at "/Users/User/Documents/Neo4j/default.graphdb/" because pre-defined directory did not exist entirely
place the csv data set here in the import folder
then run the code like - LOAD CSV FROM "file:///C:/customers.csv" AS row
In addition after you run the line, you can analyze what is going wrong in the code section to get a better understanding
you put your dataset into the import directory in neo4j-community path.
Then re-run your command.
Add your csv file in the import folder of neo4j installation guide to do this.
open neo4j and start graph of ur project
then in open folders tab open import folders
Copy ur csv file in this folder
Copy that part in ur load syntax as file:///C:/neo4j_module_datasets/test.csv since ur neo4j in running
in C drive
Snapshot for your reference
Use the following syntax:
LOAD CSV WITH HEADERS FROM "file:///my_collection.csv" AS row CREATE (n:myCollection) SET n = row
If you are running a docker then, follow these commands before running above query:
docker run \
-p=7474:7474 \
-p=7687:7687 \
-v=$HOME/neo4j/data:/data \
-v=$HOME/neo4j/logs:/logs \
-v=$HOME/local_import_dir:/var/lib/neo4j/import \
neo4j:3.0
Then,
sudo cp my_collection.csv /home/bajju/local_import_dir/
One of the following should solve the LOAD CSV errors (assuming you have dbms.security.allow_csv_import_from_file_urls=true)
If using Linux check for the permissions for the file. Change it using chmod 777 file_name.csv
Check if the file format/format for the contents within the file is correct.
The easiest way (be ware of security) is to serve you directory over http and use the http import
in the command line go the folder where csv files are lcoated
run the following depending on your python env.
Python 2
$ python -m SimpleHTTPServer 8000
Python 3
$ python3 -m http.server 8000
- Now you can load your files from your local host
LOAD CSV FROM 'http://localhost:8000/mycsvfile.csv' AS row
return row
- you can actually expose files on one host and load them where your DB is running by exposing the folder and replacing localhost with your IP

How do I import a .tar.gz file on Windows/WAMP/phpmyadmin

My web host just sent me a database back up from last week that I'd like to take a look at but it's a .tar.gz
phpmyadmin doesn't recognise the file in my import folder, just .sql files. And Sypex Dumper isn't picking it up either.
I decompressed it in 7-Zip but no dice with .tar either.
I am on Windows 7 and use Wamp too.
Any ideas?