Maketrans not working for petl with python3.4

I am using petl package which i have installed using pip in virtulaenv with python 3.4. when i tried to test that whether the petl package is installed properly or not in the python shell I have done this to check

$ python 
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from petl import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.env/lib/python3.4/site-packages/petl/__init__.py", line 10, in <module>
    from petl.util import header, fieldnames, data, records, rowcount, look, see, \
  File "/home/user/.env/lib/python3.4/site-packages/petl/util.py", line 14, in <module>
    from string import maketrans
ImportError: cannot import name 'maketrans'
>>>

I tried to check whether maketrans is present in string package i run this

>>> from string import maketrans
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'maketrans'
>>> 

Found that the default python string package does not have this . I am not sure that why petl package have used this without mentioning it in its dependency and if its the default python package then why its giving import error.

Not sure what is happening can any one please help

Update: petl >= 1.0 supports Python 3.4.


Clearly petl does not work on Python 3.x.

This specific error is because the Python 2.x string.maketrans function doesn't exist in 3.x.* But if you got past that, you'd find lots of other errors.

While the PyPI entry doesn't list supported versions (which it really should), a quick google turned up Issue #240, to add Python 3 support, which has been on the backlog since 26 Aug 2014. And a 2to3 pass over the source shows hundreds of issues.**

So, how do you fix this?

  1. Use something other than petl.
  2. Use Python 2.7 for your petl work.
  3. Help port it.

* Actually, in 3.0, it still existed, but only worked on bytes objects. In 3.1, maketrans and translate methods were added to bytes and bytearray, equivalent to the ones on str, and the string functions were deprecated, and then in 3.2 or 3.3 they were removed.

** Some of these issues are using things that were already deprecated in 2.6 or 2.7, which is odd given that petl originally worked only in 2.7, and was later ported to also work in 2.6.

python 3 issues. · Issue #1 · TeamErlich/dna-fountain · GitHub, I was trying it out and I have the following configuration: Python 3.6.0 /​27539884/maketrans-not-working-for-petl-with-python3-4/27540139). The maketrans() method returns a translation table that maps each character in the intabstring into the character at the same position in the outtab string. Then this table is passed to the translate() function. Note − Both intab and outtab must have the same length. Syntax. Following is the syntax for maketrans() method −

In Python2, maketrans is a function belongs to the string module. However in Python3, maketrans is a static method of the str type.

Python cannot import maketrans, Maketrans not working for petl with python3.4 - Stack Overflow https://​stackoverflow.com/questions/27539884/maketrans-not-working-for-petl-with-​python3-4. String maketrans() Parameters. The maketrans() method takes 3 parameters: x - If only one argument is supplied, it must be a dictionary. The dictionary should contain 1-to-1 mapping from a single character string to its translation OR a unicode number (97 for 'a') to its translation.

Because I was looking for a clear example of how it works in python 3.4, I post what I've found:

#in py2 you need to "from string import maketrans" 
table = "".maketrans('cs', 'kz')
#py2 table = maketrans('cs', 'kz')
len(table)
#in py2 you will get **len(table) = 256 in py3.4 len(table) = 2**
sentence = "cause koala is causing trouble"
sentence.translate(table)

Python 3 - String maketrans() Method, Python 3 - String maketrans() Method - The maketrans() method returns a translation table that maps each character in the intabstring into the character at the  Python | maketrans() and translate() functions In the world of programming, seldom there is a need to replace all the words/characters at once in the whole file python offers this functionality using functions translate() and its helper functions maketrans().

use str to invoke maketrans

LETTERS = 'abcdefghijklmnopqrstuvwxyz'
NUMBERS = '22233344455566677778889999'
## translate a-z char to phone digits
TRANS = str.maketrans(LETTERS, NUMBERS)

[PDF] An introduction to Python Programming for Research, 1.5.4 Gettinghelponfunctionsandmethods . 2.1.4 The python file type . Python is free, so you'll never have a problem getting hold of it, wherever you go. 1.1.3 Why write programs for 'maketrans', class Pet(object):. Hello, First of all thanks for this great project. I was trying it out and I have the following configuration: Python 3.6.0 |Anaconda 4.3.0 (x86_64)| (default, Dec 23 2016, 13:19:00) After compilation and building, I can not run encode.p

Cannot import name maketrans from string, Cannot import name maketrans from string. 4/11/2013 · Gossamer Mailing List Archive. The string module Maketrans not working for petl with python3. static str.maketrans(x[, y[, z]]) This static method returns a translation table usable for str.translate(). It's saying that the arguments passed to str.maketrans, along with the actual function str.maketrans, will make a table that says, "If this character appears, replace it with this character." However, I'm not sure what the brackets are for.

What's New In Python 3.1, The string.maketrans() function is deprecated and is replaced by new static methods, of binary floating point representation as being a problem with Python itself). The itertools.combinations_with_replacement() function is one of four for  please simplify your question as something like how to translate string.maketrans in python3 and accept your answer, again simplified as "replace string.maketrans with str.maketran". – Искрен Станиславов Jul 26 '18 at 12:43

Text Processing · Python Basics, the first argument to maketrans() is string characters to be replaced, the get number of times character sequence is present (non-overlapping) M, Multiline mode, ^ and $ anchors work on lines from math import factorial >>> numbers = '1 2 3 4 5' >>> def fact_num(n): pet = re.compile(r'dog') >>> type(pet) <class 're. Python string method maketrans() returns a translation table that maps each character in the intabstring into the character at the same position in the outtab string. Then this table is passed to the translate() function. Note − Both intab and outtab must have the same length. Syntax. Following is the syntax for maketrans() method −