Re: What's wrong with these codes as failed to read the strings in Chinese? Is it because Chinese characters can't be read on Mac? Many thanks

2018-11-09 Thread Kevin Hu
Dear Annie,

Looks like you’re trying to read in a file with encoded characters. By default 
Python3 reads file in bytes, and you’ll need to decode it. Looks like it’s 
utf-8 encoding.

More at: https://docs.python.org/3/howto/unicode.html 


You can simply add:

namelist_decoded = namelist1801txt.decode(‘utf-8’)

Which should give you the actual characters:

> 陈巍\n胡智健\r黄坤榕\r李星灿\r刘超杰

Some tutorials lying around Internet:

https://www.programiz.com/python-programming/methods/string/encode 


https://www.pythoncentral.io/encoding-and-decoding-strings-in-python-3-x/ 


Regards,
Kevin

> On Nov 8, 2018, at 21:30, Annie Lu  wrote:
> 
> # -*- coding: UTF-8 -*-
> ... f = open('/Users/annielu/Desktop/namelist1801.txt')
 namelist1801txt = f.read()
 f.close()
 namelist1801txt
> '\xe9\x99\x88\xe5\xb7\x8d\n\xe8\x83\xa1\xe6\x99\xba\xe5\x81\xa5\r\xe9\xbb\x84\xe5\x9d\xa4\xe6\xa6\x95\r\xe6\x9d\x8e\xe6\x98\x9f\xe7\x81\xbf\r\xe5\x88\x98\xe8\xb6\x85\xe6\x9d\xb0\r\xe7\x8e\x8b\xe4\xbf\x8a\xe5\x80\xbc\r\xe4\xbd\x99\xe4\xb8\x9c\xe6\xbd\xae\r\xe9\x99\x88\xe6\x80\x9d\xe5\x87\xbd\r\xe5\x86\xaf\xe5\xb0\x91\xe5\x90\x9b\r\xe9\xbb\x84\xe5\x98\x89\xe8\xb0\x8a\r\xe9\xbb\x84\xe7\x90\xaa\xe7\x90\xaa\r\xe8\xb5\x96\xe5\xa9\x89\xe5\xa9\xb7\r\xe8\xb5\x96\xe5\xbd\xa6\xe9\x9c\x8f\r\xe5\xbb\x96\xe7\xbf\xa0\xe7\x9b\x88\r\xe6\x9e\x97\xe7\xbe\xbd\xe7\x8f\x82\r\xe5\x88\x98\xe5\xae\x89\xe7\x90\xaa\r\xe9\xa9\xac\xe7\x91\x9e\r\xe5\xbd\xad\xe5\x98\x89\xe4\xbb\xaa\r\xe9\x82\xb1\xe6\xaf\x93\xe4\xbb\xaa\r\xe5\xad\x99\xe6\xa3\xae\xe6\xa3\x8b\r\xe8\xb0\xad\xe5\x98\x89\xe7\x90\xaa\r\xe7\x8e\x8b\xe5\xa4\xa9\xe9\x9f\xb5\r\xe5\x90\xb4\xe5\xad\x90\xe7\x8f\xba\r\xe6\x9d\xa8\xe5\x88\xa9\xe8\x8c\xb5\r\xe5\xa7\x9a\xe5\x98\x89\xe9\x9b\xaf\r\xe8\xa2\x81\xe6\x9c\x88\xe6\xbb\xa2\r\xe5\xbc\xa0\xe9\x87\x87\xe7\x8e\
> x89\r\xe5\xbc\xa0\xe6\xb2\x81\xe7\x8e\xa5'
 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Cloud platform with GPU

2018-11-09 Thread denis meng
Good day all,

I am looking for a good cloud platform to do all my python development for
machine learning with GPU availability, so far I have used Amazon ec2,
google colab, kaggle etc but none of them was very satisfactory.

Anyone has good experience with other options? please share and TIA

Denis
-- 
https://mail.python.org/mailman/listinfo/python-list


Anyone running Python on MS Azure?

2018-11-09 Thread Malcolm Greene
Curious to hear if any of you are running Python scripts/apps on MS
Azure cloud services? What services are you using and what has your
experience been? Advice?
Background: Customer migrating to Azure. I'm trying to get ahead of the curve 
regarding how Python-friendly the Azure platform is.
Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows file associations fix

2018-11-09 Thread eryk sun
On 11/9/18, David Raymond  wrote:
>
> And why does the Python installer have a check box for "Associate files with
> Python" if it then promptly proceeds to destroy all those associations?
> Could we maybe get that part of the installer fixed for future versions?

The installer configures the HKCR setting to associate .py[w] files;
however, it doesn't delete a user-choice setting in the shell. You
should be able to restore the user choice to the launcher via the
open-with -> choose another app dialog. Select the Python icon with a
rocket on it (for py.exe; the python.exe icon has no rocket), enable
the option to always use this application, and click ok.

If that doesn't restore the association, you'll have to manually
inspect and modify the settings. The following lists the shell's
cached association for the .py file extension, including the user
choice, if any:

set "winkey=HKCU\Software\Microsoft\Windows\CurrentVersion"
reg query %winkey%\Explorer\FileExts\.py /s

Output:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\FileExts\.py\OpenWithList
aREG_SZpy.exe
MRUListREG_SZa

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\FileExts\.py\OpenWithProgids
Python.FileREG_NONE

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\FileExts\.py\UserChoice
HashREG_SZaA7ZxnDmUdM=
ProgIdREG_SZPython.File

Currently I have a UserChoice setting locked in. The permissions and
hash value prevent us from modifying this key, but we can delete it,
in which case the shell reverts to using the cached OpenWith*
associations. Here's a command to delete this key (or use regedit if
you prefer a GUI), where %winkey% was previously defined above:

reg delete %winkey%\Explorer\FileExts\.py\UserChoice

If we instead delete the FileExts\.py key, the shell recomputes the
association from the underlying HKCR settings, where HKCR is a merged
view of [HKLM | HKCU]\Software\Classes.

If that doesn't solve the problem, check the default value of [HKCU |
HKLM]\Software\Classes\.py, and its OpenWithProgIds subkey if defined.
Python's installer associates .py files with the "Python.File" program
identifier (progid).

If that's set correctly, check [HKCU |
HKLM]\Software\Classes\Python.File to ensure it's set up to use the
py.exe launcher. For example, the following displays the default
"open" command for the local-machine Python.File progid:

reg query HKLM\Software\Classes\Python.File\shell\open\command

Output:

HKEY_LOCAL_MACHINE\Software\Classes\Python.File\shell\open\command
(Default)REG_SZ"C:\Windows\py.exe" "%1" %*

"%1" (or sometimes "%L") is the fully-qualified path of the target .py
script, and %* has the command-line arguments, if any.

As a side note, you've probably seen examples that use CMD's assoc and
ftype commands (from NT 4.0, circa 1996). These commands work with
HKLM\Software\Classes, which is fine for classic file associations
configured for all users. However, they do not show or modify HKCU
settings, and they're unaware of updates to how the shell works since
XP/Vista such as HKCR\Applications, HKCR\SystemFileAssociations, and
application capability file associations linked in [HKCU |
HKLM]\Software\RegisteredApplications.

> Currently: Windows 7. Attempting to run a .py file opens up the "Open with"
> dialog with a bunch of other programs listed. Clicking browse to manually
> select the new python.exe doesn't add it to the list and won't let me do the
> association.

You shouldn't manually associate .py files by browsing for py.exe or
python.exe. If you do this, the system creates an automatic progid
that only includes the "%1" target, without the %* command-line
arguments. Typically this broken progid will be
"HKCU\Software\Classes\Applications\py.exe", or
"HKCU\Software\Classes\Applications\python.exe", or
"HKCU\Software\Classes\py_auto_file". Delete these keys if they exist.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows file associations fix

2018-11-09 Thread boB Stepp
On Fri, Nov 9, 2018 at 10:02 AM David Raymond  wrote:

> Currently: Windows 7. Attempting to run a .py file opens up the "Open with" 
> dialog with a bunch of other programs listed. Clicking browse to manually 
> select the new python.exe doesn't add it to the list and won't let me do the 
> association.
>
> Do have administrator permissions, did do the install "for all users", did 
> include the py launcher, have tried repairing, reinstalling and rebooting.
>
> Did look at the "Python on Windows FAQ" 
> (https://docs.python.org/3/faq/windows.html#how-do-i-make-python-scripts-executable)
>  which confirms the installer should set it up to work the way I'm looking 
> for and had it previously.
>
> The rest of the installation is fine, the only issue is the file associations.

I do not know if this is relevant or not for Windows 7, but during the
past week my phone's Google news feed had an article about a recent
Windows *10* update breaking file associations.  Might a recent
Windows *7* update have done the same?

-- 
boB
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: Wing Python IDE 6.1.2 released

2018-11-09 Thread Wingware

Hi,

We've just released Wing 6.1.2 , 
which allows creating a new virtualenv 
 from the New Project 
dialog, implements VI mode inner/all text object operations such as ciw 
and das, exits VI insert mode when jk is typed rapidly, fixes reporting 
of top-level exceptions and skipped tests in pytest, supports 
goto-definition links 
 in 
docstrings, allows setting the main debug file from editor tabs and the 
Open Files tool, remembers current tab in preferences and properties 
dialogs, and makes many other improvements.For details, see 
https://wingware.com/pub/wingide/6.1.2/CHANGELOG.txt


Download Now 

About Wing

Wingware's family of cross-platform 
 Python IDEs make 
Python development easier, with powerful integrated editing, debugging, 
unit testing, and project management features. Wing runs on Windows, 
Linux, and OS X, and can be used to develop any kind of Python code for 
web, desktop, scientific, data analysis, embedded scripting, and other 
applications.


Version 6 introduces many new features, including improved 
multi-selection , 
much easier remote development 
, debugging from the Python 
Shell , recursive 
debugging , PEP 484 
and 526 type hinting 
, PEP 8 
reformatting , support for Python 3.6 
and 3.7, ability to create a new virtualenv 
 from the New Project 
dialog, improved VI mode, support for Vagrant 
, Jupyter 
, Django 
 1.10+ and 2.0, and Windows 
Subsystem for Linux , improved 
support for matplotlib , 
easier Raspberry Pi  
development, optimized debugger, OS X full screen mode, One Dark color 
palette, Russian localization (thanks to Alexandr Dragukin), expanded 
free product line, and much more. For details, see What's New in Wing 
Version 6 .


Wing 6 works with Python versions 2.5 through 2.7 and 3.2 through 3.7, 
including also Anaconda, ActivePython, EPD, Stackless, and others 
derived from the CPython implementation.


Wing Pro 
 requires purchasing 
 or upgrading 
 a license, or obtaining a 30-day 
trial at startup. Wing 101  and 
Wing Personal  are free 
versions that omit some features .


For more product information, please visit wingware.com 



Upgrading

You can try Wing 6 without removing older versions. Wing 6 will read and 
convert your old preferences, settings, and projects. Projects should be 
saved to a new name since previous versions of Wing cannot read Wing 6 
projects.


See also Migrating from Older Versions 
 and Upgrading 
.


Links

Release notice: https://wingware.com/news/2018-11-08
Downloads and Free Trial: https://wingware.com/downloads
Buy: https://wingware.com/store/purchase
Upgrade: https://wingware.com/store/upgrade

Questions?  Don't hesitate to email us at supp...@wingware.com.

Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com

--
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-09 Thread Cousin Stanley
srinivasan wrote:

> Even after changing as per the below
> "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
> or:
> 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
> or:
> "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"
> 
> Still my output is:
> */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"*
> 
> My expected output should be only:
> *vfat*
> 
> Could you guys please do the needful?

 
  I tried a simiar command line from a rock64 sbc shell
  and found that  -f2  instead of  -f3  returned only  vfat 
   

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pandas read_csv

2018-11-09 Thread Venkatesh Adiga
Sharan
I had similar issue of reading different column sized csv file... Instead
of using pandas I used csv reader which handles with no error...
Regards
Venkat

On Fri, 9 Nov 2018, 8:28 pm Sharan Basappa, 
wrote:

> are there any requirements about the format of the CSV file when using
> read_csv from pandas?
> For example, is it necessary that the csv file has to have same number of
> columns in every line etc.
>
> I am trying to load a csv file and I get the following error.
> I really don't know what the issue is ...
> Any help is appreciated ...
>
> ParserErrorTraceback (most recent call last)
> D:\Projects\Initiatives\machine learning\programs\log\log_analysis_1.py in
> ()
>  10
>  11 #data_df = pd.read_csv("BGL_MERGED.log", nrows=100, header=None,
> delimiter=r'\s"')
> ---> 12 data_df = pd.read_csv("d:\Projects\Initiatives\machine
> learning\programs\log\BGL_MERGED.log", nrows=100, header=None)
>  13 logger.debug("data frame %s \n", data_df)
>  14 print('Cols %d' %(len(data_df.columns)))
> D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
> in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col,
> usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters,
> true_values, false_values, skipinitialspace, skiprows, nrows, na_values,
> keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates,
> infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator,
> chunksize, compression, thousands, decimal, lineterminator, quotechar,
> quoting, escapechar, comment, encoding, dialect, tupleize_cols,
> error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote,
> delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory,
> buffer_lines, memory_map, float_precision)
> 653 skip_blank_lines=skip_blank_lines)
> 654
> --> 655 return _read(filepath_or_buffer, kwds)
> 656
> 657 parser_f.__name__ = name
> D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
> in _read(filepath_or_buffer, kwds)
> 409
> 410 try:
> --> 411 data = parser.read(nrows)
> 412 finally:
> 413 parser.close()
> D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
> in read(self, nrows)
>1003 raise ValueError('skipfooter not supported for
> iteration')
>1004
> -> 1005 ret = self._engine.read(nrows)
>1006
>1007 if self.options.get('as_recarray'):
> D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
> in read(self, nrows)
>1746 def read(self, nrows=None):
>1747 try:
> -> 1748 data = self._reader.read(nrows)
>1749 except StopIteration:
>1750 if self._first_chunk:
> pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.read
> (pandas\_libs\parsers.c:10862)()
> pandas/_libs/parsers.pyx in
> pandas._libs.parsers.TextReader._read_low_memory
> (pandas\_libs\parsers.c:11343)()
> pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_rows
> (pandas\_libs\parsers.c:11884)()
> pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows
> (pandas\_libs\parsers.c:11755)()
> pandas/_libs/parsers.pyx in pandas._libs.parsers.raise_parser_error
> (pandas\_libs\parsers.c:28765)()
> ParserError: Error tokenizing data. C error: Expected 1 fields in line 8,
> saw 3
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pandas read_csv

2018-11-09 Thread Peter Otten
Sharan Basappa wrote:

> are there any requirements about the format of the CSV file when using
> read_csv from pandas? For example, is it necessary that the csv file has
> to have same number of columns in every line etc.

> ParserError: Error tokenizing data. C error: Expected 1 fields in line 8, 
saw 3

The error message is quite clear, look for extra fields in line 8 of your 
data ;)

Now let's make a few experiments:

>>> import pandas, io
>>> def dump(s):
... return pandas.read_csv(io.StringIO(s))
... 
>>> dump("""foo,bar
... 1,2
... """
... )
   foo  bar
012

[1 rows x 2 columns]
>>> dump("""foo,bar
... 1,2,3
... 4,5
... """)
   foo  bar
123
45  NaN

[2 rows x 2 columns]
>>> dump("""foo,bar
... 1,2
... 3,4,5
... """)
Traceback (most recent call last):
  File "", line 4, in 
  File "", line 2, in dump
  File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 420, in 
parser_f
return _read(filepath_or_buffer, kwds)
  File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 225, in 
_read
return parser.read()
  File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 626, in 
read
ret = self._engine.read(nrows)
  File "/usr/lib/python3/dist-packages/pandas/io/parsers.py", line 1070, in 
read
data = self._reader.read(nrows)
  File "parser.pyx", line 727, in pandas.parser.TextReader.read 
(pandas/parser.c:6937)
  File "parser.pyx", line 749, in pandas.parser.TextReader._read_low_memory 
(pandas/parser.c:7156)
  File "parser.pyx", line 802, in pandas.parser.TextReader._read_rows 
(pandas/parser.c:7757)
  File "parser.pyx", line 789, in pandas.parser.TextReader._tokenize_rows 
(pandas/parser.c:7640)
  File "parser.pyx", line 1697, in pandas.parser.raise_parser_error 
(pandas/parser.c:19092)
pandas.parser.CParserError: Error tokenizing data. C error: Expected 2 
fields in line 3, saw 3

>From this I infer that no row in the csv file may contain more columns than 
the first data row. Missing columns are added automatically.

There is also an option to suppress rows containing too many columns:

>>> pandas.read_csv(io.StringIO("foo,bar\n1,2\n3,4,5\n6,7"), 
error_bad_lines=False)
b'Skipping line 3: expected 2 fields, saw 3\n'
   foo  bar
012
167

[2 rows x 2 columns]


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pandas read_csv

2018-11-09 Thread Rob Gaddi

On 11/9/18 6:54 AM, Sharan Basappa wrote:

are there any requirements about the format of the CSV file when using read_csv 
from pandas?
For example, is it necessary that the csv file has to have same number of 
columns in every line etc.

I am trying to load a csv file and I get the following error.
I really don't know what the issue is ...
Any help is appreciated ...

ParserErrorTraceback (most recent call last)
D:\Projects\Initiatives\machine learning\programs\log\log_analysis_1.py in 
()
  10
  11 #data_df = pd.read_csv("BGL_MERGED.log", nrows=100, header=None, 
delimiter=r'\s"')
---> 12 data_df = pd.read_csv("d:\Projects\Initiatives\machine 
learning\programs\log\BGL_MERGED.log", nrows=100, header=None)
  13 logger.debug("data frame %s \n", data_df)
  14 print('Cols %d' %(len(data_df.columns)))
D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
 in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, 
usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, 
true_values, false_values, skipinitialspace, skiprows, nrows, na_values, 
keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, 
infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, 
chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, 
escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, 
warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, 
as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, 
float_precision)
 653 skip_blank_lines=skip_blank_lines)
 654
--> 655 return _read(filepath_or_buffer, kwds)
 656
 657 parser_f.__name__ = name
D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
 in _read(filepath_or_buffer, kwds)
 409
 410 try:
--> 411 data = parser.read(nrows)
 412 finally:
 413 parser.close()
D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
 in read(self, nrows)
1003 raise ValueError('skipfooter not supported for 
iteration')
1004
-> 1005 ret = self._engine.read(nrows)
1006
1007 if self.options.get('as_recarray'):
D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
 in read(self, nrows)
1746 def read(self, nrows=None):
1747 try:
-> 1748 data = self._reader.read(nrows)
1749 except StopIteration:
1750 if self._first_chunk:
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.read 
(pandas\_libs\parsers.c:10862)()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_low_memory 
(pandas\_libs\parsers.c:11343)()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_rows 
(pandas\_libs\parsers.c:11884)()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows 
(pandas\_libs\parsers.c:11755)()
pandas/_libs/parsers.pyx in pandas._libs.parsers.raise_parser_error 
(pandas\_libs\parsers.c:28765)()
ParserError: Error tokenizing data. C error: Expected 1 fields in line 8, saw 3



Offhand, and as a guess based on nothing, I would speculate that 
something about line 8 of your CSV file differs from lines 1-7.


--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
--
https://mail.python.org/mailman/listinfo/python-list


Windows file associations fix

2018-11-09 Thread David Raymond
Would some kind person be so good as to point me to instructions on how to fix 
Windows file associations and default programs for the various Python 
extensions (.py/.pyw/etc)? I know I've fixed this before after installing a new 
version, but didn't save the instructions, and apparently my searching skills 
are getting worse as the tips I'm finding at the moment aren't helping.

And why does the Python installer have a check box for "Associate files with 
Python" if it then promptly proceeds to destroy all those associations? Could 
we maybe get that part of the installer fixed for future versions?

Desired state: Double click a .py file and have it run in a new console. Being 
able to just type "foo.py" in a command prompt and have it run without needing 
to run "{python|py|explicit-python-executable} foo.py"

Currently: Windows 7. Attempting to run a .py file opens up the "Open with" 
dialog with a bunch of other programs listed. Clicking browse to manually 
select the new python.exe doesn't add it to the list and won't let me do the 
association.

Do have administrator permissions, did do the install "for all users", did 
include the py launcher, have tried repairing, reinstalling and rebooting.

Did look at the "Python on Windows FAQ" 
(https://docs.python.org/3/faq/windows.html#how-do-i-make-python-scripts-executable)
 which confirms the installer should set it up to work the way I'm looking for 
and had it previously.

The rest of the installation is fine, the only issue is the file associations.

Any patient assistance appreciated.

Thank you,
-- 
https://mail.python.org/mailman/listinfo/python-list


pandas read_csv

2018-11-09 Thread Sharan Basappa
are there any requirements about the format of the CSV file when using read_csv 
from pandas?
For example, is it necessary that the csv file has to have same number of 
columns in every line etc.

I am trying to load a csv file and I get the following error.
I really don't know what the issue is ...
Any help is appreciated ...

ParserErrorTraceback (most recent call last)
D:\Projects\Initiatives\machine learning\programs\log\log_analysis_1.py in 
()
 10 
 11 #data_df = pd.read_csv("BGL_MERGED.log", nrows=100, header=None, 
delimiter=r'\s"')
---> 12 data_df = pd.read_csv("d:\Projects\Initiatives\machine 
learning\programs\log\BGL_MERGED.log", nrows=100, header=None)
 13 logger.debug("data frame %s \n", data_df)
 14 print('Cols %d' %(len(data_df.columns)))
D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
 in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, 
usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, 
true_values, false_values, skipinitialspace, skiprows, nrows, na_values, 
keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, 
infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, 
chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, 
escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, 
warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, 
as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, 
float_precision)
653 skip_blank_lines=skip_blank_lines)
654 
--> 655 return _read(filepath_or_buffer, kwds)
656 
657 parser_f.__name__ = name
D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
 in _read(filepath_or_buffer, kwds)
409 
410 try:
--> 411 data = parser.read(nrows)
412 finally:
413 parser.close()
D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
 in read(self, nrows)
   1003 raise ValueError('skipfooter not supported for 
iteration')
   1004 
-> 1005 ret = self._engine.read(nrows)
   1006 
   1007 if self.options.get('as_recarray'):
D:\Users\sharanb\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\pandas\io\parsers.pyc
 in read(self, nrows)
   1746 def read(self, nrows=None):
   1747 try:
-> 1748 data = self._reader.read(nrows)
   1749 except StopIteration:
   1750 if self._first_chunk:
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.read 
(pandas\_libs\parsers.c:10862)()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_low_memory 
(pandas\_libs\parsers.c:11343)()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_rows 
(pandas\_libs\parsers.c:11884)()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows 
(pandas\_libs\parsers.c:11755)()
pandas/_libs/parsers.pyx in pandas._libs.parsers.raise_parser_error 
(pandas\_libs\parsers.c:28765)()
ParserError: Error tokenizing data. C error: Expected 1 fields in line 8, saw 3
-- 
https://mail.python.org/mailman/listinfo/python-list


​PyDev 7.0.3 Released

2018-11-09 Thread Fabio Zadrozny
PyDev 7.0.3 Release Highlights
---

* **Mypy**

* PyDev can now use Mypy when doing code analysis.

* **Black Formatter**

* PyDev can now use black as the code formatting engine.

* **Virtual environments**

* It's now possible to use pipenv for managing virtual environments.
* It's possible to manage virtual environments from the editor.

* Ctrl+2, pip 
* Ctrl+2, pipenv 
* Ctrl+2, conda 

* **Debugger**

* Should be **much** faster for those on Python 3.6 onwards with cython
extensions (using frame evaluation).

* The Python 3.7 grammar is now available as an option (even though it's
the same as 3.6).

* Removed support for using the Python 2.4 grammar.

* The 2to3 integration shows a better dialog.

* It's possible to autogenerate docstring parameters using the Google Code
format (patch by ghbcode).

About PyDev
---

PyDev is an open-source Python IDE on top of Eclipse for Python, Jython and
IronPython development, now also available for Python on Visual Studio Code.

It comes with goodies such as code completion, syntax highlighting, syntax
analysis, code analysis, refactor, debug, interactive console, etc.

It is also available as a standalone through LiClipse with goodies such as
multiple cursors, theming and support for many other languages, such as
Django Templates, Jinja2, Html, JavaScript, etc.

Links:

PyDev: http://pydev.org
PyDev Blog: http://pydev.blogspot.com
PyDev on VSCode: http://pydev.org/vscode
LiClipse: http://www.liclipse.com
PyVmMonitor - Python Profiler: http://www.pyvmmonitor.com/

Cheers,

Fabio Zadrozny
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-09 Thread Chris Angelico
On Fri, Nov 9, 2018 at 11:11 PM Anssi Saari  wrote:
>
> Chris Angelico  writes:
>
> > No helper needed. Safe against command injection. Uses the known
> > format of the command's output; if you want other information as well
> > as the type, you could get that too.
>
> Can someone let me in on this secret helper module? Doesn't seem to
> match the helper module in PyPI at least.
>

What helper? I said you don't need one. Just use subprocess directly.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-09 Thread Anssi Saari
Chris Angelico  writes:

> No helper needed. Safe against command injection. Uses the known
> format of the command's output; if you want other information as well
> as the type, you could get that too.

Can someone let me in on this secret helper module? Doesn't seem to
match the helper module in PyPI at least.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with these codes as failed to read the strings in Chinese? Is it because Chinese characters can't be read on Mac? Many thanks

2018-11-09 Thread Peter Otten
Cameron Simpson wrote:

> In Python 3 the loop is much cleaner:
> 
>   with open('namelist.txt', encoding='utf-8') as f:
> for line in f:
>   line = line.strip()
>   print("line =", line)

In Python 2.7 you can use io.open():

import io 

with io.open('namelist.txt', encoding='utf-8') as f:
for line in f:
line = line.strip()
print "line =", line

However, if you have the choice go with Python 3 which is where all 
improvements to the language and its libraries go.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how can I solve this problem simply and clearly

2018-11-09 Thread Karsten Hilbert
On Fri, Nov 09, 2018 at 09:45:50AM +0800, lampahome wrote:

> def __Init__():

There's a typo right there.

Karsten
-- 
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B
-- 
https://mail.python.org/mailman/listinfo/python-list