Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Using -f is opening the file in binary mode #52

Open
mscaldas2012 opened this issue Feb 27, 2017 · 8 comments
Open

Using -f is opening the file in binary mode #52

mscaldas2012 opened this issue Feb 27, 2017 · 8 comments

Comments

@mscaldas2012
Copy link

Hi, I tried running a series of queries saved on a file through cycle , but it's complaining that the file is binary?
I was using -f flag. After many trials, i did with --filename and it worked fine !

aren't those two flags have the same behavior?

@nicolewhite
Copy link
Owner

Hmm what OS are you on?

@rajfal
Copy link

rajfal commented Jan 4, 2018

Hi Nicole,
I have enjoyed the cypher side of Cycli

However, I am experiencing exactly the same problem as above but with both -f and --filename flags
Can't get cypher queries processed from a file
My OS is Ubuntu 5.4.0-6ubuntu1~16.04.5

TypeError: a bytes-like object is required, not 'str'

THank you for your help

@nicolewhite
Copy link
Owner

What version of Python are you on?

@rajfal
Copy link

rajfal commented Jan 10, 2018

Python 3.6.0 :: Anaconda 4.3.0 (64-bit)

@victoriastuart
Copy link

victoriastuart commented Mar 30, 2018

Arch Linux x86_64; Python 2.7; Python 3.5; Cycli 0.7.6

I also just encountered this issue with Cycli v.0.7.6 (pip install ...) operating in a Python 3.5 venv.

`TypeError: a bytes-like object is required, not 'str'`
(py35) [victoria@victoria ~]$ cycli -P 7474 -u victoria -p <my_password> -f glycolysis2.cypher

Traceback (most recent call last):
  File "/home/victoria/anaconda2/envs/py35/bin/cycli", line 11, in <module>
    sys.exit(run())
  File "/home/victoria/anaconda2/envs/py35/lib/python3.5/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/home/victoria/anaconda2/envs/py35/lib/python3.5/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/home/victoria/anaconda2/envs/py35/lib/python3.5/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/victoria/anaconda2/envs/py35/lib/python3.5/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/home/victoria/anaconda2/envs/py35/lib/python3.5/site-packages/cycli/main.py", line 284, in run
    cycli.run()
  File "/home/victoria/anaconda2/envs/py35/lib/python3.5/site-packages/cycli/main.py", line 72, in run
    queries = queries.split(";")[:-1]

TypeError: a bytes-like object is required, not 'str'

(py35) [victoria@victoria ~]$

@danodonovan
Copy link
Contributor

@victoriastuart I believe this PR #60 should correct that issue (it uses io to safely handle the file opening for python 2 and 3).

@victoriastuart
Copy link

@nicolewhite, @danodonovan: this is great, thank you!!

For referencing this issue, here is how I updated my Cycli install (git clone this repo | make | make install | pip uninstall / install cycli | test execute cypher file):

[victoria@victoria apps]$ pwd
    /mnt/Vancouver/apps

[victoria@victoria apps]$ git clone https://github.com/nicolewhite/cycli

[victoria@victoria apps]$ cd cycli

## Update repo, after Nicole's 2018-04-05 merge commit
## https://github.com/nicolewhite/cycli/pull/60

[victoria@victoria cycli]$ git pull
    ...

[victoria@victoria cycli]$ p3                                                                                                              
    [Anaconda Python 3.5 venv (source activate py35)]

[victoria@victoria cycli]$ p3
    [Anaconda Python 3.5 venv (source activate py35)]

(py35) [victoria@victoria cycli]$ pwd
  /mnt/Vancouver/apps/cycli

(py35) [victoria@victoria cycli]$ pip uninstall cycli
    Uninstalling cycli-0.7.6:
    ...

(py35) [victoria@victoria cycli]$ make
    ...

(py35) [victoria@victoria cycli]$ py.test tests
    ...
    ================= 82 passed in 0.33 seconds ================================

(py35) [victoria@victoria cycli]$ make clean
    rm -rf build dist cycli.egg-info

(py35) [victoria@victoria cycli]$ pip install cycli
    ...

(py35) [victoria@victoria cycli]$ cycli -P 7474 -u victoria -p <password_obfuscated_here>
 ______     __  __     ______     __         __    
/\  ___\   /\ \_\ \   /\  ___\   /\ \       /\ \   
\ \ \____  \ \____ \  \ \ \____  \ \ \____  \ \ \  
 \ \_____\  \/\_____\  \ \_____\  \ \_____\  \ \_\ 
  \/_____/   \/_____/   \/_____/   \/_____/   \/_/ 
Cycli version: 0.7.6
Neo4j version: 3.3.4
Bug reports: https://github.com/nicolewhite/cycli/issues

> quit
Goodbye!

(py35) [victoria@victoria cycli]$ cycli -P 7474 -u victoria -p <password_obfuscated_here> -f /mnt/Vancouver/Programming/data/metabolism/glycolysis.cypher

> LOAD CSV WITH HEADERS FROM "file:/mnt/Vancouver/Programming/data/metabolism/pg2neo4j/glycolysis_bioentities.csv" AS row
MERGE (n:Glycolysis {name:row.name})
  // RETURN n, labels(n), n.name;
270 ms
...

(py35) [victoria@victoria cycli]$

@fraewn
Copy link

fraewn commented May 14, 2019

Hi there, I'm still having the same issue under windows with neo4j 3.5.5. did neither work with -f nor with --filename. i was trying to open a cyp file
Also btw needed to change/add an encoding after this error occured to get the program to work at all: SyntaxError: Non-UTF-8 code starting with '\xfc' in file cycli-script.py (after entering "cycli -u ")
great program tho! thx

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

No branches or pull requests

6 participants