I've imported a csv file (Baguette.csv), and the header have accents.

I am trying to use this function :

Code:

`def delete_accent(line):`

accent = ['é', 'è', 'ê', 'ë', 'à', 'â', 'ä', 'ù', 'ü', 'û', 'ç', 'ô', 'î', 'ï']

without_accent = ['e', 'e', 'e', 'e', 'a', 'a', 'a', 'u', 'u', 'u', 'c', 'o', 'i', 'i']

i = 0

while i < len(accent):

line = line.replace(accent[i], without_accent[i])

i += 1

return line

with this :

Code:

`headerline=baguette[["Name", "Boulangerie préférée", "Distance"]] `

delete_accent(headerline)

What did i do wrong ?

Thank you in advance :)

Note : I'm using the Jupyter notebook (Python 3) ]]>

Code:

`from random import randint`

lp = 1

mp = 2

sp = 3

r1 = 50

r2 = 125

r3 = 175

r4 = 100

r5 = 125

r6 = 45

lpM = 0

mpM = 0

spM = 0

lpF = 0

spF = 0

mpF = 0

add = 0

flight = 0

kg = 1

pas = 0

while kg == 1:

while flight < 8:

print "Large Plane Flights"

lpf = input ("Route Number: ")

flight = flight + 2

if lpF == 1:

pas = randint(48,60)

lpM = lpM + (pas*50*2)

if lpF == 2:

pas = randint(42,52)

lpM = lpM + (pas*125*2)

if lpF == 3:

pas = randint(38,57)

lpM = lpM + (pas*175*2)

if lpF == 4:

pas = randint(53,64)

lpM = lpM + (pas*100*2)

if lpF == 5:

pas = randint(57,70)

lpM = lpM + (pas*125*2)

if lpF == 6:

pas = randint(52,62)

lpM = lpM + (pas*45*2)

print lpM

print pas

"unindent does not match any outer indentation level"

and i pressed format-> ident region

and still it gives me that error

Code:

` class HouseLocation:`

def __init__(self,x,y,street_name):

"""how to check if its non negative"""

"""lizrok exception??"""

self.x=x

self.y=y

if x>39 or x<0 or y<0 or y>39:

raise ValueError("invalid x or y value")

self.street_name=street_name

def print_address(self):

print self.street_name, ": ",self.x,",",self.y

class Street:

def __init__(self,street_name,map_symbol,street_ends):

self.street_name=street_name

self.house_locations={}

if map_symbol.islower()==False:

""" difference between " and ' """

raise ValueError("symbol must be a single lowercase letter!")

else:

self.map_symbol=map_symbol

if street_ends[0][0]>39 or street_ends[0][0]<0:

raise ValueError("ends out of range!")

if street_ends[0][1]>39 or street_ends[0][1]<0:

raise ValueError("ends out of range!")

if street_ends[1][0]>39 or street_ends[1][0]<0:

raise ValueError("ends out of range!")

if street_ends[1][1]>39 or street_ends[1][1]<0:

raise ValueError("ends out of range!")

if street_ends[0][0]==street_ends[0][1] and street_ends[0][1]==street_ends[1][1]:

raise ValueError("ends are identifical!")

def valid_house_to_add(self, house):

return isBetween(self.street_ends[0], (house.x,house.y), self.street_ends[1]) and self.house_locations.has_key((x,y))

def add_house(self,house):

if valid_house_to_add(self, house)==True:

self.house_locations= {(house.x,house.y):True}

else:

raise ValueError("invaid adrees for this street")

class City:

def __init__(self,city_name):

self.streets=[]

self.city_name=city_name

def valid_street_to_add(self,test_street):

"""can i write only self in for"""

for i in range(len(self.streets)):

if self.streets[i].map_symbol==test_street.map_symbol or self.streets[i].street_name==test_street.stree_name :

return False

else:

return True

def add_street(self,street):

if self.valid_street_to_add(street)==True:

self.streets.append(street)

def print_map(self):

map = []

for i in range(1,40): """empty 2d array"""

map.append(['_'])

for j in range(1,40):

map[i].append('_')

for i in self.streets:

for j in self.streets[i].house_locations(j):

map[self.streets[i].house_locations(j).x],[self.streets[i].house_locations(j).y]=self.streets[i].map_symbol

def isBetween(a, b, c):

crossproduct = (c[1] - a[1]) * (b[0] - a[0]) - (c[0] - a[0]) * (b[1] - a[1])

if abs(crossproduct) != 0 : return False

dotproduct = (c[0] - a[0]) * (b[0] - a[0]) + (c[1] - a[1])*(b[1] - a[1])

if dotproduct < 0 : return False

squaredlengthba = (b[0] - a[0])*(b[0] - a[0]) + (b[1] - a[1])*(b[1] - a[1])

if dotproduct > squaredlengthba: return False

return True

Please help me resolve issue.

I have a large text file and i have to remove duplicate lines.

The problem is that sometimes the duplication spans multiple lines

For example first two lines is unique and they repeat three times.

I have to remove this pairs of repeated lines.

I must delete duplicates only if they appear one after another.

The condition is met before the appearance of some other lines,

it means that we have to start again checking count of unique lines which will be repeated.

Quote:

Test line 1

Test line 2

Test line 1

Test line 2

Test line 1

Test line 2

Some other lines

............

Test line 1

Test line 2

Test line 3

Some other lines

............

Test line 1

Test line 2

Test line 3

Test line 1

Test line 2

Test line 3

Test line 1

Test line 2

Test line 3

Some other lines

............

Test line 1

Test line 1

Test line 1

Some other lines

............

Test line 1

Test line 2

Test line 3

Test line 4

Test line 1

Test line 2

Test line 3

Test line 4

Some other lines

............

Expected result

Quote:

Test line 1

Test line 2

Some other lines

............

Test line 1

Test line 2

Test line 3

Some other lines

............

Test line 1

Test line 2

Test line 3

Some other lines

............

Test line 1

Some other lines

............

Test line 1

Test line 2

Test line 3

Test line 4

Some other lines

............

We just launched rinocloud.com, it aims to make it easy to manage datasets in python. I hope some of you could take a look at it and give us some feedback. https://github.com/rinocloud/rinocloud-python

We made the library to create a better way to organize datasets and parameters from simulations and experiments

Instead of just saving files, and not recording parameters, Rinocloud is an easy way to attach essentially a dict to a file object. Meaning you can save all you parameters with your data.

With rinocloud-python you can organize your datasets locally, and if you choose too, you can upload them to Rinocloud. If you upload them you then get a fully query system.

Soon we are implementing notebooks and collaboration features –so if your working in a team, you’ll be able to discuss your results inside one central storage system.

Please, let me know if you have suggestions of questions, you can get me at helena at rinocloud.com

Cheers,

Helena. ]]>

I am trying to do a soap query from python.

I am newbee and in need for help.

I have a soap service that runs on joomla and a virtuemart extenstion.

I am tryint to do a "search" on my server.

I would like to search for a "tag" and filter on it...

My script today is:

import requests

url="http://webserver/VM_ProductWSDL.php"

headers = {'content-type': 'application/soap+xml'}

body = """<?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vm="http://www.virtuemart.net/VM_Product/">

<soapenv:Header/>

<soapenv:Body>

<vm:GetProductFromSKURequest>

<!--You may enter the following 3 items in any order-->

<loginInfo>

<!--You may enter the following 4 items in any order-->

<login>soap</login>

<password>demo</password>

<isEncrypted>?</isEncrypted>

<lang>?</lang>

</loginInfo>

<product_sku>Do1</product_sku>

<include_prices>?</include_prices>

</vm:GetProductFromSKURequest>

</soapenv:Body>

</soapenv:Envelope>"""

response = requests.post(url,data=body,headers=headers)

print response.content

I would like to search for conect "Do1" in the tag <product_sku>

Have anyone tryed to do a soap post/query from Python?

Any tips will be nice..

Tnx for all answers..

Eddie ]]>

Given a 1700 digit number, we want to store the value and perform two functions on it

with NO loss of accuracy, its ok if calc time takes longer but better if faster.

Where x = a 1700 digit long numeric value

The two calcs to be computed with be ;

X * (up to a four digit value )

then we take the modulus of this resultant of 400 ;

( x % 400 )

If we cant multiply [ X * (up to a four digit value ) ] and then take the modulus due to

processing bottlenecks, ceilings - then can this be done where we first take the

modulus of the original x = 1700 digits and then multiply this by the four digit value

and then take the modulus of this after? Ideally Id prefer to be able to do the

first scenario.

Constraints Im aware of regarding this to date ;

Firstly, Im only running on a WinXp 32 bit system and not able to upgrade currently.

Secondly, Ive been becoming aware of a lot of issues, bugs, errors with python, sympy,

etc.. in properly handling very large number calcs. These problems seem to arise

out of data loss through use of floats and related. Details on a number of different

approaches can be viewed here ;

https://groups.google.com/forum/#!to...py/eUfW6C_nHdI

https://groups.google.com/forum/#!to...py/hgoQ74iZLkk

My system will not properly handle "float128" floats, although Ive been told

by one person this would be able to handle wsuch a computation - altho the prob

is it seems that float128 is rarely actually a 128 float and certainly not on my system.

Also due to internal processing peculiarties it seems that most floats will lose

data on these kinds of computations. If I understand correctly, one of the best

candidates for getting the most accurate values returned involves the use

of arbitrary precision and representing the inputs as strings and not just straight numeroc

values? Also, ideally, Id like the formula to be able to handle rationals without

accuracy loss. So "x" starts off as a whole number, but when I multiply it

by the four digit value, Id like that value to be any numeric value such as an integer,

whole number or rational like "2243.0456".

Structure of one of the methods Ive been experimenting with ;

from sympy import mpmath

mpmath.mp.dps = 1700

x = (mpmath.mpf" INSERT 1700 DIGIT NUMBER HERE"

(x % 400)

An example with live data ;

from sympy import mpmath

mpmath.mp.dps = 1700

x = (mpmath.mpf"4224837741562986738552195234618134569391350587851527986076117152972791626026988760293885 7540687684754239199916768168607014789965397150769686494316682629415524992728519340217447037997287979 6234685948177214196472012081393478142073226015644670174040859126428974596098581128907024623835926826 7313892549883722768575435935465369820850766441187744058828599331364172396647692768693734233545999439 0714351290827643404462920579623433601144636965159508031598952386672373568872945496184892961577163844 9429515985106050005037194052338570194686096416256906737117535761514419234476387654081388210737989159 1055307476597279137714860430053785074855035948744902479909111840444834198237419177418965268614345042 6346556482378188992531162479165856867132431930746356085271602736113090519387626765205074048151807927 9370125921660931611848383521679126317290247012382111177922320473564793137702722705531294093475632561 1832463728974558417085791096461266371917752574370345933533929245534623041989305973992490523694190318 2846664647571593248660968615737045406541606447112747667595205010136339997062441176912358781234896942 6172415807372564489752772747345003761529548763733868784835144133138694641600371879541982224693578768 2977520303924734875834943985619000970655639767984458204513958680501990182471695393372003272654902387 4939558497753089229016310241990112834410508816086868567462060122708909842604248343295512812497975457 7509122643366903668046340628385841342372293529785977878694593575146804849408142768966973066466026090 8636113264573712854536295005312934569838992758429422872122606102877623867968067833225444280667381025 371705347744037508121975424674439904984528128036994803804742198422695627759844248"

(x % 400)

But I have no idea if accurate results are being returned with this, would love to hear anyones suggestions? ]]>

Hi All!

I was reading Dr Knotts entries about Binets formula on his fibonacci page

A Formula for the nth Fibonacci number

I entered the formula into an Excel spreadsheet to see how this would work ;

Binet Formula

Fib(n) = (1.6180339^n – (–0.6180339..)^n) / 2.236067977..

Its fascinating to see how I can enter any number for (n) and see the

correct fibonacci number returned!

I have a question though, I am a newbie computer programmer using

VB and Python and my math skills are average at best but I am very

interest and curious about math and especially fibonacci numbers!

Say I wanted to reverse and change the process.

I have a very large fibonacci number and I want to know what the

fibonacci number is at a specified position BEFORE it, how would

I compute this, what would the formula be?

So for example I have the 301 st fibo number of ;

359579325206583560961765665172189099052367214309267232255589801

And I want to be able to find what the fibonacci value would be (n) numbers

BEFORE this... so I might want to know what the fibo value would be 50

numbers before or the 251st fibo number. How would I do that? ]]>

I've been trying to solve a problem with numpy and other code routines

to raise a base to a large power and then take the modulus.

Precision accuracy is very important, speed isnt as much - although it would

be convenient if I didnt have to wait a long long time for processing.

Constraints Im under is that Im working on a winxp system, Im using

python 3.4 and numpy version 1.1.

When using numpy Ive been using the code lines;

import numpy

(np.longdouble(1.4142)** 6000 )%400

I am not sure how accurate the result is, and I have tried using other methods too

but recently I found a post comparing sympy to numpy and it seems someone

is claiming that sympy can return superior precision results, can anyone confirm

that this is true and do you know if this would be a good solution to run on my system?

Link with info comparing the below is shown ;

how set numpy floating point accuracy? - Stack Overflow

In normal numpy use, the numbers are double. Which means that the accuracy will be less than 16 digits. Here is a solved subject that contains the same problematic ...

If you need to increase the accuracy, you can use symbolic computation .... The library mpmath ... is a quiet good one. The advantage is that you can use limitless precision. However, calculations are slower than what numpy can do.

Here is an example:

# The library mpmath is a good solution

>>> import sympy as smp

>>> mp = smp.mpmath

>>> mp.mp.dps = 50 # Computation precision is 50 digits

# Notice that the difference between x and y is in the digit before last (47th)

>>> x = smp.mpmath.mpf("0.910221324013388510820732335560023784637451171875")

>>> y = smp.mpmath.mpf("0.910221324013388510820732335560023784637451171865")

>>> x - y # Must be equal to 1e-47 as the difference is on the 47th digit

mpf('1.000014916280995001003481719184726944958705912691304e-47')

You can't do better with numpy. You can calculate exponentials with a better accuracy.

smp.exp(x).evalf(20) = 2.4848724344693696167

how set numpy floating point accuracy? - Stack Overflow

https://github.com/sympy/sympy/releases

Welcome to SymPy ]]>

I'm a newbie to Python and still learning the basics!

I am trying to write a simple python script that I can

run from the Python3.4 command line.

What I would like to be able to do is have the script prompt

the users for four numeric outputs, then once the fourth input

is made the script runs a simple numpy formula, computes

and then spits out two resultant values to screen.

I only know very little python code but I understand language

basics, the algorithm is shown roughly below - if anyone could

show me how to structure this properly with working python code

I would honestly appreciate it very much! :)

See below ;

X = any numeric value between 1000 to 6000

Y = any numeric value between 1 to 5000

Xb = any numeric value between 1000 to 6000

Yb = any numeric value between 1 to 5000

For X, Prompt for entry with text ; Enter value for X

input X from console and store

For Y, Prompt for entry with text ; Enter value for Y

input Y from console and store

For Xb, Prompt for entry with text ; Enter value for Xb

input Xb from console and store

For Y, Prompt for entry with text ; Enter value for Yb

input Yb from console and store

import numpy as np

>>> Y * ((np.longdouble(1.4142))** X )%400

>>> Yb * ((np.longdouble(1.4142))** Xb )%400

print output to screen so that it shows something like this ;

>>>"Y gives = (display value)"

>>> Yb gives = (display value)" ]]>

I am currently a final year computing student at Staffordshire University. For my final module I am writing a report on Python frameworks and especially the Django framework. As part of this report I need some primary research and was hoping some people on this forum could take a couple of minutes to complete the following survey.

Python Frameworks Questionnaire

Any replies would be greatly appreciated.

Many thanks. ]]>

For example:

x= "hello"

print x.upper() ]]>

import math

print math.sqrt(25)

I get an error message:

Last login: Fri Mar 25 01:48:48 on ttys001

/var/folders/92/n0xpf5ld4nj8cfwr3f5ky9dr0000gn/T/math-480577894.445.py.command ; exit;

Waffle-MacBook-Air:~ waffle$ /var/folders/92/n0xpf5ld4nj8cfwr3f5ky9dr0000gn/T/math-480577894.445.py.command ; exit;

Traceback (most recent call last):

File "/Users/waffle/Dropbox/myprojects/python/math.py", line 1, in <module>

import math

File "/Users/waffle/Dropbox/myprojects/python/math.py", line 2, in <module>

print math.sqrt(25)

AttributeError: 'module' object has no attribute 'sqrt'

logout

Saving session...

...copying shared history...

...saving history...truncating history files...

...completed.

[Process completed]

But if I run in IDLE, it works.

Just cannot figure out why I cannot import the math module from TextWrangler.

Any suggestion is very much appreciated! Thank you! ]]>