python-2.7

Convert CSV file with values spareted in comma to multi columns CSV file

穿精又带淫゛_ 提交于 2021-01-28 06:00:12
问题 I want to create a small program to convert a CSV file with one column containing values separated by comma, to CSV file containing multiple columns with one value: input file: output file: Therefor I write this code: my_string1 = 'A,B,C,D,E' my_string2 = 'A,B,C,D,E' my_string3 = 'A,B,C,D,E' my_list1 = my_string1.split(",") my_list2 = my_string2.split(",") my_list3 = my_string3.split(",") path = 'C:\Dokumente\\n_1.csv' rows = zip(my_list1,my_list2,my_list3) with open(path, "wb") as csv_file:

scrapy is there a way to print json file without using -o -t parameters

情到浓时终转凉″ 提交于 2021-01-28 05:55:45
问题 I am usually calling my spider like this: scrapy crawl Spider -o fileName -t json and I got the correct data printed in the fileName file as json formated. Now I want to call my spider like this: scrapy crawl Spider my question is there a way to print the output to a file without using the -o -t parameters? 回答1: Yes it can be done. add this to your settings FEED_EXPORTERS = { 'jsonlines': 'scrapy.contrib.exporter.JsonLinesItemExporter', } FEED_FORMAT = 'jsonlines' FEED_URI = "NAME_OF_FILE

Google Cloud DataFlow job throws alert after few hours

坚强是说给别人听的谎言 提交于 2021-01-28 05:43:41
问题 Running a DataFlow streaming job using 2.11.0 release. I get the following authentication error after few hours: File "streaming_twitter.py", line 188, in <lambda> File "streaming_twitter.py", line 102, in estimate File "streaming_twitter.py", line 84, in estimate_aiplatform File "streaming_twitter.py", line 42, in get_service File "/usr/local/lib/python2.7/dist-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper return wrapped(*args, **kwargs) File "/usr/local/lib/python2

lxml and xml namespaces - Using find and findall to get XML Tag Value

冷暖自知 提交于 2021-01-28 05:31:02
问题 I had issues in getting the text value of and nodes using lxml where the XML text has namespaces in it. I was using findall('Status') but the result was always coming to null. I arrived at the following working code in the end....Is this the correct way of using lxml for fetching node values? Can i improve this further? import lxml xml_string='<?xml version="1.0" encoding="UTF-8"?> <SCPP:Response xmlns:SCPP="http://www.SCPP.com/XMLSchema"> <SCPP:RESP_BODY> <Seed>001335834994</Seed> </SCPP

Jupyter Notebook - install python 2

百般思念 提交于 2021-01-28 05:07:30
问题 EDITED I'm very new to python and have a probably super basic question. I've installed Jupyter Notebook by installing anaconda which includes python 3 by default. Now I want to use an external toolbox which still works with python 2.7, so I'm trying to get e kernel with python 2.7 as suggested here. In the Anaconda Prompt I'm typing python2 -m pip install ipykernel python2 -m ipykernel install --user But it says that it couldn't find the command "python2". Any idea? 回答1: I had the same issue.

scapy 3 way handshake

不问归期 提交于 2021-01-28 05:07:11
问题 I am trying to build a scapy 3 way handshake. But when I send an Acknowledgement packet in response of SYN-ACK packet, I receive a FA packet instead of completion of 3 way handshake. My code is. from scapy.all import* ip = IP(dst = "192.168.0.1") syn = TCP(dport=35021, flags="S", seq=100) synack = sr1(ip/syn, iface = "D-Link DUB-E100 USB 2.0 Fast Ethernet Adapter") ack = TCP(dport=35021, flags="A", seq=101, ack=synack.seq+1) ans=sr1(ip/ack, iface = "D-Link DUB-E100 USB 2.0 Fast Ethernet

standalone py.test (ignore __init__.py files)

五迷三道 提交于 2021-01-28 05:00:59
问题 I have a simple python module (let's call it M1) which is standalone (the only import is to collections ), inside a package containing ugliness. Part of the ugliness is in the package's __init__.py file. But M1 is nice and clean, and contains some test functions for use with py.test. Now, I would like to test M1 and ignore all the ugliness. But py.test wants to run __init__.py -- is there any way I can prevent this? I really can't fix the __init__.py file at this time, and I want to keep my

How to install Flask-mysqldb for Python?

蓝咒 提交于 2021-01-28 04:42:43
问题 I am new to Python and Python-Flask and have ran into an error. I am using Ubuntu 18.04.3 LTS and Python 2.7.15+ to build a python-flask web application. When installing flask-mysqldb I run into an error. $ pip install flask-mysqldb The full output: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2

pip installs modules for python2.7 instead of python3.4

拟墨画扇 提交于 2021-01-28 04:40:12
问题 I have an Amazon EC2 instance. On that was just python 2.7 installed. So I installed Python3 with the command "sudo yum install python34". Then I tried to install modules with "pip install package". The terminal told me, that I can upgrade pip. So i upgraded pip. No my instance either find the command pip or pip3. I googled and find that I have to use "python -m pip install SomePackage" I installed a module and tried to start one of my scripts with "python3 script.py" I got the information

Matplotllib and Xelatex

时光毁灭记忆、已成空白 提交于 2021-01-28 04:31:06
问题 I tried to find the answer for my question for some time now but could not come up with something that works for me. My question is: How can you use Xelatex to compile text in Matplotlib? I know that there is this page: http://matplotlib.org/users/pgf.html However, I could not come up with something that would work. What I got up to now: import matplotlib as mpl mpl.use("pgf") ## TeX preamble preamble = """ \usepackage{fontspec} \setmainfont{Linux Libertine O} """ params = {"text.usetex":