What happens when you do use UTF-8?
This is the result when I encode the string:
étroits, en utilisant un portable extrêmement puissant—le plus
petit et le plus léger des HP EliteBook pleine puissance—avec un
écran de diagonale 31,75 cm (12,5 pouces), idéal pour le
professionnel
What's your terminal's encoding? That looks like you have a CP-1252
terminal trying to output UTF-8 text.
Thanks for your answer, I tried locale in my terminal and it gives
this as an output:
LANG=en_US
LC_CTYPE=en_US
LC_NUMERIC=en_US
LC_TIME=en_US
LC_COLLATE=en_US
LC_MONETARY=en_US
if you only see encoding problems on printing results to your
terminal, its settings or unicode capability might be the cause,
however, if you also get badly encoding items in the database, you are
likely using an inappropriate encoding in some step.
I get badly encoding into my DB
you seem
Hi,
I don't know, what the product ID would look like, for this page, but
assuming, the catalog pages are also utf-8 encoded as well as the
error page I get, it should work ok; cf.:
You are right, I get it work on Windows too, but not in Linux. I
changed the codec of linux, but still I don't
src.decode() is creating a unicode string. The error is not happening
there. But when print is used with a unicode string, it has to encode
the data. And for whatever reason, yours is using latin-1, and you have
a character in there which is not in the latin-1 encoding.
I fixed the print, I
I fixed the print, I changed the setting of the terminal and also on
the sshconfig, so now when I print I'm able to print out without
problems, but when I tried to run the script I've made it gives me
again the same error :
Unexpected error: exceptions.UnicodeEncodeError
Maybe I will try
I doubted that 2.7 would make any difference.
Yeah this complicated my life even more, all my import functions was
gone - took me 2h to fix all :)
and it does not solved my issue:)
1. What does your terminal' expect. (For all I know you're using
TeraTermPro as a terminal, which doesn't
Just realize that once you start using 'ignore' you're going to also
ignore discrepancies that are real. For example, maybe your terminal is
actual something other than either latin-1 or utf-8.
If you need to see such discrepancies, you can do
print src.decode(utf-8).encode(latin-1,
SSCCE starts with Short. The HTML you unloaded into that email
hardly qualifies.
When you're trying to figure out a problem that appears to happen only
when you have X and not when you have Y, see what the smallest example
data for X and Y are that continue to exhibit the difference. It's
Hello guys,
Excuse me for the noob question, but is there a way to compare a field
in mysql as lower() somehow?
I have a situation where I compare the SKU in my DB and there are some
SKU that are with lowercase and some with uppercase, how can I solve
this in your opinion ?
def
I think this will work:
sql = 'UPDATE product SET price=%s WHERE LOWER(sku)=%s'
cursor.execute(sql, (price, sku.lower())
Thanks John, this works, I was about to make double check with lower
and upper, but this saves me :)
Thanks a lot.
--
Hi all,
I'm facing an issue inserting an html code into the DB, it comes out
with a syntax error but I face it only when I have html code. Could
help me escape the error somehow ?
Here is my code
def InsertSpecsDB(product_id, spec, lang, name):
db = MySQLdb.connect(localhost,getit,opencart)
As much use as a chocolate teapot, all you've given is a function/method
definition. No indication of your OS, Python version, calling code, what
you expect to happen, what actually happened, apart from that your request
for assistance is perfect. Usually I'd be able to help but sadly my
On Tue, Dec 11, 2012 at 1:29 AM, Anatoli Hristov toli...@gmail.com wrote:
As much use as a chocolate teapot, all you've given is a function/method
definition. No indication of your OS, Python version, calling code, what
you expect to happen, what actually happened, apart from that your request
You're using a parametrised query (which is good :-)), but you've included
quotes around the placeholders. There's no need to do that. They'll be
quoted automatically when necessary:
sql = INSERT INTO product_description (product_id, language_id, name,
description) VALUES (%s,%s,%s,%s)
First thing -- DON'T put quotes around the %s place-holders... The
whole purpose of using the parameterized .execute() is to let the
database adapter properly escape the parameters before putting them into
the SQL (since MySQL didn't have prepared statements before v5, it was
producing
Calling it 'found' is misleading, because it's True only if it updated.
If it found a match but didn't update, 'found' will still be False.
Using a loop within a loop like this could be the cause of your
problem. It's certainly not the most efficient way of doing it.
I will keep you posted
On Thu, Dec 6, 2012 at 1:31 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
On Wed, 05 Dec 2012 23:50:49 +0100, Anatoli Hristov wrote:
def Change_price():
Misleading function name. What price does it change?
total = 0
tnf = 0
tnf? Does that mean something
Guys I'm still confusing my script is working better, but not enough.
I did a logfile to see which products are not found anymore in the CSV
and I found some that are present but python says they are not ??
Here is the product in the CSV:
MONIIE2407HDS-B1;MON;II;E2407HDS-B1;E2407HDS-B1;IIYAMA LCD
On Thu, Dec 6, 2012 at 3:22 PM, Anatoli Hristov toli...@gmail.com wrote:
Guys I'm still confusing my script is working better, but not enough.
I did a logfile to see which products are not found anymore in the CSV
and I found some that are present but python says they are not ??
Here
No one have an idea ?
Thanks
Basically because your code is crap. Others have already suggested
refactoring your code to make it easier to follow.
Thank you Mark for your notes. I changed the name of the variables as
was suggested before.
I know my code should be crappy, but at least I
Here is the product in the CSV:
MONIIE2407HDS-B1;MON;II;E2407HDS-B1;E2407HDS-B1;IIYAMA LCD 24 Wide
1920x1080TN Speakers 2ms Black DVI HDMI;133;20;RECTD0.41;0,41;
This one is still not found and it is in the CSV file - I just don't
get it why !
if len(db_sku) != 0
Here is the product in the CSV:
MONIIE2407HDS-B1;MON;II;E2407HDS-B1;E2407HDS-B1;IIYAMA LCD 24 Wide
1920x1080TN Speakers 2ms Black DVI HDMI;133;20;RECTD0.41;0,41;
[snip]
It's not saying that it's not found, it's saying that it wasn't updated
because:
You are right, the price at the
gmane.comp.python.general:
But basically, the code seems to run a pair of nested for-loops:
for SKU in database:
for SKU in csv file:
if the two SKUs match:
compare their prices and update the database
OUCH...
I'm presuming the CSV is restarted
Hi all,
I'm confused again with a compare update function. The problem is that
my function does not work at all and I don't get it where it comes
from.
in my DB I have total of 754 products. when I run the function is says:
Total updated: 754
Total not found with in the distributor: 747
I just
Hello,
I tried to read a CSV file with 3 products in it and index it into
a list using
file = open(ShopPrices.csv, rbU)
reader = csv.reader(file, delimiter=;)
mylist = []
for x in reader:
mylist.append(x)
The problem comes when I try to index the SKU array and the field is empty
for
On Tue, Dec 4, 2012 at 12:31 PM, Thomas Bach
thb...@students.uni-mainz.de wrote:
Hi there,
Please be a bit more precise…
On Tue, Dec 04, 2012 at 12:00:05PM +0100, Anatoli Hristov wrote:
The problem comes when I try to index the SKU array and the field is
empty
Can you provide an example
The issue is now solved I did:
for x in mylist:
try:
sku.append(x[4])
except IndexError:
pass
Thank you for your help
Anatoli
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Dec 4, 2012 at 2:58 PM, Neil Cerutti ne...@norwich.edu wrote:
On 2012-12-04, Anatoli Hristov toli...@gmail.com wrote:
The issue is now solved I did:
for x in mylist:
try:
sku.append(x[4])
except IndexError:
pass
Thank you for your help
Optionally
Can you print ex_phone first. You are opening the files in text mode
so I wonder if the line endings are causing you to read and extra
line in between. Can you try reading the csv as rb instead of
rt?
Yes I did this: use the global list PHONELIST and opening the CSV in
binary - it works now
As I said before, process both files into lists, one that you treat as
constant (and therefore capitalized) and the other containing the data
you intend to modify.
It'd be much cleaner if you did all that input file parsing stuff in one
function, returning only the lists. Call it just
On Tue, Nov 27, 2012 at 9:41 PM, Neil Cerutti ne...@norwich.edu wrote:
On 2012-11-27, Anatoli Hristov toli...@gmail.com wrote:
Thank you all for the help, but I figured that out and the
program now works perfect. I would appreciate if you have some
notes about my script as I'm noob :) Here
On Tue, Nov 27, 2012 at 4:23 AM, Dave Angel d...@davea.name wrote:
On 11/26/2012 05:27 PM, Anatoli Hristov wrote:
I understand, but in my case I have for sure the field Name in the
second file that contains at least the first or the last name on it...
So probably it should be possible
On Tue, Nov 27, 2012 at 4:05 PM, Neil Cerutti ne...@norwich.edu wrote:
On 2012-11-27, Anatoli Hristov toli...@gmail.com wrote:
Thanks for your help. I will do my best for the forum :)
I advanced a little bit with the algorithm and at least I can
now extract and compare the fields :) For my
, 2012 at 11:08 PM, Dave Angel d...@davea.name wrote:
On 11/26/2012 04:08 PM, Anatoli Hristov wrote:
Hello,
I'm trying to complete a namebook CSV file with missing phone numbers
which are in another CSV file.
the namebook file is structured:
First name;Lastname; Address; City; Country; Phone
Hello,
I need an advice about a small script I run 24/24 7/7.
It's a script converted to EXE using py2exe and this script takes -
grows 30kb RAM on each loop which means that for 10hours it grows up
with 180mb memory. is there something I can do ?
From the ini file I'm loading only the URL and
that it
grows up with 30kb.
And I'm using Python 2.7 on windows 7
Thanks
On 22 Oct 2012, at 02:21, Dave Angel d...@davea.name wrote:
On 10/21/2012 08:02 PM, Anatoli Hristov wrote:
Hello,
I need an advice about a small script I run 24/24 7/7.
It's a script converted to EXE using py2exe
Thank you,
I will test this, will keep you posted.
Anatoli
On Wed, Oct 17, 2012 at 7:47 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
On Wed, Oct 17, 2012 at 8:07 AM, Anatoli Hristov toli...@gmail.com wrote:
Hello,
Can you please help me out how can I change the computername of
windows XP
It does not work the result is 0
And I don't find any documentation about it :(
On Thu, Oct 18, 2012 at 8:41 AM, Anatoli Hristov toli...@gmail.com wrote:
Thank you,
I will test this, will keep you posted.
Anatoli
On Wed, Oct 17, 2012 at 7:47 PM, Ian Kelly ian.g.ke...@gmail.com wrote
Hello,
I'm trying to index a text in a list as I'm importing a log file and
each line is a list.
What I'm trying to do is find the right line which contains the text
User : and take the username right after the text User :, but the
list.index((User :) is indexing only if all the text matching.
Thanks a lot this solved my issue:)
Regards
Anatoli
On Wed, Oct 17, 2012 at 12:23 PM, Chris Angelico ros...@gmail.com wrote:
On Wed, Oct 17, 2012 at 9:10 PM, Anatoli Hristov toli...@gmail.com wrote:
Hello,
I'm trying to index a text in a list as I'm importing a log file and
each line
...@johnohagan.comwrote:
On Tue, 3 Apr 2012 23:00:22 +0200
Anatoli Hristov toli...@gmail.com wrote:
On 03 Apr 2012, at 22:45, Ian Kelly ian.g.ke...@gmail.com wrote:
On Tue, Apr 3, 2012 at 2:36 PM, Anatoli Hristov toli...@gmail.com
wrote:
Hi,
I'm trying to do a while loop with condition
Hi,
I'm trying to do a while loop with condition of time if time is
12:00:00 print text, but for this one second the text is printed at
least 50 times, how can I print only once?
Thank
Anatoli
--
http://mail.python.org/mailman/listinfo/python-list
On 03 Apr 2012, at 22:45, Ian Kelly ian.g.ke...@gmail.com wrote:
On Tue, Apr 3, 2012 at 2:36 PM, Anatoli Hristov toli...@gmail.com wrote:
Hi,
I'm trying to do a while loop with condition of time if time is
12:00:00 print text, but for this one second the text is printed at
least 50 times
Ramit,
This seems to be more logic now I hope :)
#
import ast
fname = 0
lname = 1
country = 2
city = 3
tel = 4
notes = 5
## Read data from file
def load_book():
load_book = open('c:/Python27/Toli/myfile.txt', 'r')
load_book =
**
Absolutely! Too bad your version would be considered the more
“complicated” version ;)
I`m sure about that, but I`am also sure that every beginner passed true
that way.
** **
With the main navigation menu I will only have the option to select a
nickname and when a nickname is
You are correct it is not. :) You code is overly complex making it harder
to understand. Try and reduce the problem to the least number of tasks you
need.
From the Zen of Python, Simple is better than complex. It is a good
programming
mentality.
Complex is better than complicated. :p
2.
Um, at least by my understanding, the use of Pickle is also dangerous if
you
are not completely sure what is being passed in:
Oh goodness yes. pickle is exactly as unsafe as eval is. Try running this
code:
from pickle import loads
Thank you Ramit for your advice`s. I`m reading a book ( Learning Python,
Second Edition ) by Mark Lutz and David Ascher and now I just finished the
Basic Function lesson :) I will keep in mind what you have advised me, but
will implement it later when I have more experience with the book, because
This was difficult, now I feel more confused it works, but I`m sure its
not the way you wanted :)
The use of eval is dangerous if you are not *completely* sure what is
being passed in. Try using pickle instead:
http://docs.python.org/release/2.5.2/lib/pickle-example.html
I`m sure about
Thanks, but I`m still far from for dose details I thing:)
Regards
Anatoli
On Tue, Mar 27, 2012 at 5:53 PM, Tim Chase python.l...@tim.thechases.comwrote:
On 03/27/12 10:32, Prasad, Ramit wrote:
fileread = open('myfile.txt','r')
tbook = eval(fileread.read())
fileread.close()
The use of
Hi guys just wanted to share one of my first programs. Could you please
tell me, do I use a right logic ?
It works fine what I wanted to do, but is it writen in the right way? My
next step is to make it write the changes of the dictionary on the file :)
## DB
tbook = {'goodie':['Christian','Van
Hi there,
I`m again confused and its the dictionary. As dictionary does not support
append I create a variable list with dictionary key values and want to add
new values to it and then copy it again to the dictionary as I dont know
other methods.
mydict =
Thanks Chris,
It works fine, I see it will take time till I understand all the syntax :(
A.H
On Sun, Feb 5, 2012 at 4:20 PM, Chris Angelico ros...@gmail.com wrote:
On Mon, Feb 6, 2012 at 2:13 AM, Anatoli Hristov toli...@gmail.com wrote:
Hi there,
I`m again confused and its
Hi everyone,
I`m totaly new in python and trying to figure out - how to write a list to
a file with a newline at the end of each object.
I tried alot of combinations :) like:
users = ['toli','didi']
fob=open('c:/Python27/Toli/username','w')
fob.writelines(users) + '%s\N'
fob.close()
or
Anatoli
On Fri, Feb 3, 2012 at 9:56 PM, Dave Angel d...@davea.name wrote:
On 02/03/2012 03:27 PM, Anatoli Hristov wrote:
Hi everyone,
I`m totaly new in python and trying to figure out - how to write a list to
a file with a newline at the end of each object.
I tried alot of combinations
56 matches
Mail list logo