mardi 4 août 2015

PyFITS: hdulist.writeto()

I'm extracting extensions from a multi-extension FITS file, manipulate the data, and save the data (with the extension's header information) to a new FITS file.

To my knowledge pyfits.writeto() does the task. However, when I give it a data parameter in the form of an array, it gives me the error:

    'AttributeError: 'numpy.ndarray' object has no attribute 'lower''

Here is a sample of my code:

    'file = 'hst_11166_54_wfc3_ir_f110w_drz.fits'
     hdulist = pyfits.open(dir + file)'
     sci = hdulist[1].data # science image data
     exp = hdulist[5].data # exposure time data
     sci = sci*exp # converts electrons/second to electrons
     file = 'test_counts.fits'

     hdulist.writeto(file,sci,clobber=True)

     hdulist.close()

I appreciate any help with this. Thanks in advance.



via Chebli Mohamed

Form for user registration in Django

I`m trying to write the register form for my website, my code is as follows. the problem is when I press the submit button in the registration page nothing actually happens... I already appreciate your help.

register.html

<form id="reg_form" action="/register/" method="post" >
    <div class="container">
        <div class="row">

            <div class="col-md-6">
                <div class="corner" style="margin-top: 5pt;">
                    <label>قوانین عضویت:</label>

                    <div class="form-group">
                        <label for="accept">با قوانین سایت موافقم</label>
                        <input type="checkbox"  id="accept"/>
                    </div>
                </div>

               <button type="submit" class="btn btn-success" data-dismiss="modal" style="width: 100%;font-size: xx-large; margin-top: 10pt;">ثبت</button>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label for="fname">نام:</label>
                    <input type="text" class="form-control" id="fname"/>
                </div>
                <div class="form-group">
                    <label for="lname">نام خانوادگی:</label>
                    <input type="text" class="form-control" id="lname">
                </div>
                <div class="form-group">
                    <label for="email">ایمیل:</label>
                    <input type="email" class="form-control" id="email">
                </div>
                <div class="form-group">
                    <label for="phone">شماره تماس:</label>
                    <input type="text" class="form-control" id="phone">
                </div>
                <div class="form-group">
                    <label for="address">آدرس:</label>
                    <input type="text" class="form-control" id="address">
                </div>
                <div class="form-group">
                    <label for="pwd">رمز عبور:</label>
                    <input type="password" class="form-control" id="pwd">
                </div>
                <div class="form-group">
                    <label for="pwd2">تکرار رمز عبور:</label>
                    <input type="password" class="form-control" id="pwd2">
                </div>

            </div>
        </div>

    </div>
    </form>

views.py ________________________________________________________________

def register(request):
    if request.method == 'POST':
        fname=request.POST['fname']
        lname=request.POST['lname']
        email=request.POST['email']
        phone=request.POST['phone']
        address=request.POST['address']
        pwd=request.POST['pwd']

        user=User.objects.create_user(username=email, password=pwd )
        user.save()
        return HttpResponseRedirect("/home/")
    return render(request, 'Register.html')



via Chebli Mohamed

pip install requests[security] vs pip install requests: Difference

I am using Ubuntu 14.04 with python version 2.7.6. Today, when I created a new virtualenv and tried doing pip install requests , I got the error InsecurePlatformWarning.

I resolved this issue by following the instructions over here

SSL InsecurePlatform error when using Requests package

But I want to understand what is the actual difference between these two commands: pip install requests[security] and pip install requests .

1) Why does the former install 3 additional packages?

2) Are there any things that I need to take care about when I push the code to production?

3) Do they both behave the same generally?

I searched a lot on stackoverflow and elsewhere, but couldn't find the answer. If it has already been answered then please post the link.

Thanks.



via Chebli Mohamed

Plot 4th dimension with Python

I would to know if there is the possibility to plot in four dimensions using python. In particular I would to have a tridimensional mesh X, Y, Z and f(X,Y,Z) = 1 or f(X,Y,Z) = 0. So I need to a symbol (for example "o" or "x") for some specific point (X,Y,Z). I don't need to a color scale.

Note that I have 100 matrices (512*512) composed by 1 or 0: so my mesh should be 512*512*100.

I hope I have been clear! Thanks.

EDIT: This is my code:

X = np.arange(W.shape[2])
Y = np.arange(W.shape[1])
Z = np.arange(W.shape[0])
X, Y, Z = np.meshgrid(X, Y, Z)
fig = plt.figure()
ax = fig.gca(projection='3d')
for z in range(W.shape[0]):
    indexes = np.where(W[z])
    ax.scatter(X[indexes], Y[indexes], ???, marker='.')

ax.set_xlabel('X = columns')
ax.set_ylabel('Y = rows')
ax.set_zlabel('Z')
plt.show()

W is my tridimensional matrix, so: W[0], W[1], etc are 512x512 matrices. My question is: what have I to write insted of ??? in my code. I know I shouldn't ask this, but I can't understand the idea.



via Chebli Mohamed

Extract part of a url using pattern matching in python

I want to extract part of a url using pattern matching in python from a list of links

Examples:

http://ift.tt/1KNZ7nE  
http://ift.tt/1g4Fr1i   

This is my regex:

re.match(r'(http?|ftp)(://[a-zA-Z0-9+&/@#%?=~_|!:,.;]*)(.\b[a-z]{1,3}\b)(/about[a-zA-Z-_]*/?)', str(href), re.IGNORECASE)  

I want to get links ending only with /about or /about/
but the about regex selects all links with "about" word in it



via Chebli Mohamed

python ZeroDivisionError: float division by zero - how to treat it as an exception

I need to calculate the percentage of winning rate and I am having trouble with ZeroDivisionError: float division by zero when there is zero in the denominator. I would like treat it as an exception, print zero and move on to next array. Any assistance would be appreciated.

YearWinLose1 = '0'
YearWinLoseTotalHard2 = '0'

YearWinLoseTotalHard2 = float(YearWinLose1) + float(YearWinLose1)
YearWinLosePercent3 = float(YearWinLose1)/float(YearWinLoseTotalHard2)*100

if YearWinLoseTotalHard2 == 0:
   YearWinLosePercent3 == 0
   print YearWinLosePercent3
else: 
   print YearWinLosePercent3



via Chebli Mohamed

pandas - splitting columns

I have some data imported from a csv, to create something similar I used this:

data = pd.DataFrame([[1,0,2,3,4,5],[0,1,2,3,4,5],[1,1,2,3,4,5],[0,0,2,3,4,5]], columns=['split','sex', 'group0Low', 'group0High', 'group1Low', 'group1High'])
means = data.groupby(['split','sex']).mean()

so the dataframe looks something like this:

enter image description here

        group0Low   group0High  group1Low   group1High
split   sex             
0   0   123 54  95  265
    1   98  111 120 220
1   0   211 300 150 190
    1   132 250 139 86

You'll notice that each column actually contains 2 variables (group# and height). It was set up this way for running repeated measures anova in SPSS, but that's beyond the point.

Ideally, I want to use pandas to split the columns up, so I can also groupby "group", like this (I actually screwed up the order of the numbers, but hopefully the idea is clear):

enter image description here

            low high
split   sex group       
    0   0   95  265
0   0   1   123 54
    1   0   120 220
    1   1   98  111
1   0   0   150 190
    0   1   211 300
    1   0   139 86
    1   1   132 250

is how do I achieve this in pandas? Is it even possible?



via Chebli Mohamed

Python xlrd read DateTime as serial number

I have an excel which is a DateTime format. But when I read the sheet it reads as serial number.

For example, in the sheet it's 08/03/2015 but xlrd reads as 42219.

The code is pretty simple

workbook = xlrd.open_workbook(file_contents=excel_contents)
the_sheet = workbook.sheet_names()[0]
number_of_rows = the_sheet.nrows - 1
curr_row = 0
data = []

while curr_row < number_of_rows:
    curr_row += 1
    air_date = the_sheet.cell_value(curr_row, 1)
    air_time = the_sheet.cell_value(curr_row, 2)
    schedule_time = '{}:{}'.format(air_date, air_time)
    unaware = datetime.strptime(schedule_time, '%m/%d/%Y:%I:%M %p') 

The air_date which I use to translate to datetime in Python bombs out because the format is different.

This is the example excel.

enter image description here

And here's the error I got

builtins.ValueError ValueError: time data '42219.0:06:00 AM' does not match format '%m/%d/%Y:%I:%M %p'



via Chebli Mohamed

GridFS on App Engine?

I get a server error when I try to import gridfs in my app engine application made with Flask.

But, when I run that app locally, it runs fine. How can I import gridfs on App Engine?



via Chebli Mohamed

Python xlrd Exception: Unknown cell type 'n+'

I have a python script that downloads an xlsx file and parses the contents, however it's started failing at the line

 workbook = xlrd.open_workbook(fname)

with the error "Exception: Unknown cell type 'n+' in rowx=1 colx=4"

Can anyone point me in the right direction with regards to what the n+ cell type is or how to move past this error

Alternatively if anyone knows of a python module that will read an xlsx file without tripping over this cell value.

Cheers

-- EDIT --

After unzipping the file I found this in the xml of the worksheet

<c r="E2" t="n+"><v>18</v></c>



via Chebli Mohamed

Python - Random Forest - Iteratively adding trees

Good afternoon! Sorry for my English, but I need your help. I am doing some machine learning task on Python. I need to build RandomForest and than build a graph that will show how the quality of the training and test samples depends on the number of trees in the Random Forest. It is necessary each time to build a new Random Forest with a certain number of trees? Or i can somehow iteratively add trees (if it possible, can you give the exapmle of code how to do that)?



via Chebli Mohamed

Matplotlib plotting- two data sets with different no. of data points

I am trying to plot two data sets into the same graph using matplotlib. No. of data points for the first pair of (x1,y1) is 150. No. of data points for the second pair (x2,y2) is 100. Please note that the range for x1 and x2 is from 0.0 to 1.0. Only the no. of data points are different. When I try to plot these into the same graph for comparison, the error message appears that "x and y must have same first dimension". Code snippet below for your reference:

def main():
 x1,y1 = np.loadtxt('txt1.txt',unpack=True)
 x2,y2 = np.loadtxt('txt2.txt',unpack=True)
 plt.figure()
 plt.plot(x1,y1)
 plt.plot(x2,y2)
main()



via Chebli Mohamed

Django pass render_to_response template in other template

this is probably a question for absolute beginners since i'm fairly new to progrmaming. I've searched for couple of hours for an adequate solution, i don't know what else to do.

Following problem. I want to have a view that displays. e.g. the 5 latest entries & 5 newest to my database (just an example)

#views.py
import core.models as coremodels

class LandingView(TemplateView):
    template_name = "base/index.html"

    def index_filtered(request):
        last_ones = coremodels.Startup.objects.all().order_by('-id')[:5]
        first_ones = coremodels.Startup.objects.all().order_by('id')[:5]
        return render_to_response("base/index.html", 
        {'last_ones': last_ones,   'first_ones' : first_ones})  

Index.html shows the HTML content but not the content of the loop

#index.html

<div class="col-md-6">
    <p> Chosen Items negative:</p>
    {% for startup in last_ones %}
        <li><p>{{ startup.title }}</p></li>
    {% endfor %}
</div>

<div class="col-md-6">
    <p> Chosen Items positive:</p>
    {% for startup in first_ones %}
       <li><p>{{ startup.title }}</p></li>
    {% endfor %}

Here my problem:

How can I get the for loop to render the specific content?

I think Django show render_to_response in template comes very close to my problem, but i don't see a valid solution there.

Thank you for your help.

Chris

-- I edited my code and problem description based on the solutions provided in this thread



via Chebli Mohamed

how to repeat same operations for dataset subset

I have a dataset of transactions. What I'm doing is determining what customers have done just one purchase and what customer have purchased more than once.

what I did is:

 df1['Counts'] = df1.groupby(['email_address']).transform('count') # get count of repeating emails/customers

 result.ix[result.Counts >= 2,'Repeat'] = 1 # create new column with 1 for those that repeated and 0 for those who didn't
 result.ix[result.Counts <= 1,'Repeat'] = 0

This gives me the overall count. However, the data frame has an additional column with the name of the website in which the purchase was made. What I want to do is to find customers that bought more than once in the same website.

Any idea how to change the previous function to get result as a column value breakdown?



via Chebli Mohamed

Error On while accessing tweepy on google app engine

I am trying to get user timeline using tweepy on google app engine.

I was facing issue of ssl on local machine that I have resolved using "ImportError: No module named _ssl" with dev_appserver.py from Google App Engine

but when i deployed it on google app engine it is not working.

here is my screenshot

enter image description here

what I am missing?



via Chebli Mohamed

Tell if text of PDF is visible or not

I'm parsing some PDF files using the pdfminer library.

I need to know if the document is a scanned document, where the scanning machine places the scanned image on top and OCR-extracted text in the background.

Is there a way to identify if text is visible, as OCR machines do place it on the page for selection.

Generally the problem is distinguishing between two very different, but similar looking cases.

In one case there's an image of a scanned document that covers most of the page, with the OCR text behind it.

Here's the PDF as text with the image truncated: http://ift.tt/1ONm1cL

In the other case there's a background image that covers most of the page with the text in front of it.

Telling them apart is proving difficult for me.



via Chebli Mohamed

Python How to copy files inside a zip to another zip in memory?

Purpose

Split a zip archive into smaller zip archives with an evenly distributed # of files per new zip.

Example

source zip (100 files)

  • src/100-Test.zip

destination zips (25 files each):

  • destination/1.zip
  • destination/2.zip
  • destination/3.zip
  • destination/4.zip

Description

So I have been able to open the zip file and iterate through the contents to split them up, but I have not been able to write to the file. Since I didn't do anything with the zip contents I didn't think I had to do any StringIO stuff or anything?

Code

zipFileNameSrc = '100-Test.zip'
zipFile = open(zipFileNameSrc)
unzippedFile = zipfile.ZipFile(zipFile)
imgList = [(s, unzippedFile.read(s)) for s in unzippedFile.namelist() if (".jpg" or ".JPG") in s]
#image names: imgList[i][0]  and  images: imgList[i][1]

#...
#...additional logic to split into sets of 25 images
#...fileTuplesList = imgList[:25]
zipNo = 1
#zipFileDest = destination + "/" + zipSrcNm + "/" + zipNo.__str__() + ".zip"
zipFileName = zipNo.__str__() + ".zip"
zipOut = zipfile.ZipFile(zipFileName, 'w')
for i in xrange(len(fileTuplesList)):
    fileNameAndPath = fileTuplesList[i][0]
    actualFile = fileTuplesList[i][1]
    zipOut.write(fileNameAndPath, actualFile)
zipOut.close()
#move_files(zipFileName, zipFileDest)

Error

I get on this on line zipOut.write(fileNameAndPath, actualFile)

OSError: [Errno 2] No such file or directory: '100-Test/17.jpg'

Bonus

How to save the zip file to a different folder than where my script is?



via Chebli Mohamed

Celery error : result.get times out

I've installed Celery and I'm trying to test it with the Celery First Steps Doc.

I tried using both Redis and RabbitMQ as brokers and backends, but I can't get the result with :

result.get(timeout = 10)

Each time, I get this error :

Traceback (most recent call last): File "", line 11, in File "/home/mehdi/.virtualenvs/python3/lib/python3.4/site-packages/celery/result.py", line 169, in get no_ack=no_ack, File "/home/mehdi/.virtualenvs/python3/lib/python3.4/site-packages/celery/backends/base.py", line 225, in wait_for raise TimeoutError('The operation timed out.') celery.exceptions.TimeoutError: The operation timed out.

The broker part seems to work just fine : when I run this code

from celery import Celery

app = Celery('tasks', backend='redis://localhost/', broker='amqp://')

@app.task
def add(x, y):
    return x + y

result = add.delay(4,4)

I get (as expected)

[2015-08-04 12:05:44,910: INFO/MainProcess] Received task: tasks.add[741160b8-cb7b-4e63-93c3-f5e43f8f8a02]

[2015-08-04 12:05:44,911: INFO/MainProcess] Task tasks.add[741160b8-cb7b-4e63-93c3-f5e43f8f8a02] succeeded in 0.0004287530000510742s: 8

P.S : I'm using Xubuntu 64bit

EDIT :

My app.conf

{'CELERY_RESULT_DB_TABLENAMES': None, 'BROKER_TRANSPORT_OPTIONS': {}, 'BROKER_USE_SSL': False, 'CELERY_BROADCAST_QUEUE': 'celeryctl', 'EMAIL_USE_TLS': False, 'CELERY_STORE_ERRORS_EVEN_IF_IGNORED': False, 'CELERY_CREATE_MISSING_QUEUES': True, 'CELERY_DEFAULT_QUEUE': 'celery', 'CELERY_SEND_TASK_SENT_EVENT': False, 'CELERYD_TASK_TIME_LIMIT': None, 'BROKER_URL': 'amqp://', 'CELERY_EVENT_QUEUE_EXPIRES': None, 'CELERY_DEFAULT_EXCHANGE_TYPE': 'direct', 'CELERYBEAT_SCHEDULER': 'celery.beat:PersistentScheduler', 'CELERY_MAX_CACHED_RESULTS': 100, 'CELERY_RESULT_PERSISTENT': None, 'CELERYD_POOL': 'prefork', 'CELERYD_AGENT': None, 'EMAIL_HOST': 'localhost', 'CELERY_CACHE_BACKEND_OPTIONS': {}, 'BROKER_HEARTBEAT': None, 'CELERY_RESULT_ENGINE_OPTIONS': None, 'CELERY_RESULT_SERIALIZER': 'pickle', 'CELERYBEAT_SCHEDULE_FILENAME': 'celerybeat-schedule', 'CELERY_REDIRECT_STDOUTS_LEVEL': 'WARNING', 'CELERY_IMPORTS': (), 'SERVER_EMAIL': 'celery@localhost', 'CELERYD_TASK_LOG_FORMAT': '[%(asctime)s: %(levelname)s/%(processName)s] %(task_name)s[%(task_id)s]: %(message)s', 'CELERY_SECURITY_CERTIFICATE': None, 'CELERYD_LOG_COLOR': None, 'CELERY_RESULT_EXCHANGE': 'celeryresults', 'CELERY_TRACK_STARTED': False, 'CELERY_REDIS_PASSWORD': None, 'BROKER_USER': None, 'CELERY_COUCHBASE_BACKEND_SETTINGS': None, 'CELERY_RESULT_EXCHANGE_TYPE': 'direct', 'CELERY_REDIS_DB': None, 'CELERYD_TIMER_PRECISION': 1.0, 'CELERY_REDIS_PORT': None, 'BROKER_TRANSPORT': None, 'CELERYMON_LOG_FILE': None, 'CELERYD_CONCURRENCY': 0, 'CELERYD_HIJACK_ROOT_LOGGER': True, 'BROKER_VHOST': None, 'CELERY_DEFAULT_EXCHANGE': 'celery', 'CELERY_DEFAULT_ROUTING_KEY': 'celery', 'CELERY_ALWAYS_EAGER': False, 'EMAIL_TIMEOUT': 2, 'CELERYD_TASK_SOFT_TIME_LIMIT': None, 'CELERY_WORKER_DIRECT': False, 'CELERY_REDIS_HOST': None, 'CELERY_QUEUE_HA_POLICY': None, 'BROKER_PORT': None, 'CELERYD_AUTORELOADER': 'celery.worker.autoreload:Autoreloader', 'BROKER_CONNECTION_TIMEOUT': 4, 'CELERY_ENABLE_REMOTE_CONTROL': True, 'CELERY_RESULT_DB_SHORT_LIVED_SESSIONS': False, 'CELERY_EVENT_SERIALIZER': 'json', 'CASSANDRA_DETAILED_MODE': False, 'CELERY_REDIS_MAX_CONNECTIONS': None, 'CELERY_CACHE_BACKEND': None, 'CELERYD_PREFETCH_MULTIPLIER': 4, 'BROKER_PASSWORD': None, 'CELERY_BROADCAST_EXCHANGE_TYPE': 'fanout', 'CELERY_EAGER_PROPAGATES_EXCEPTIONS': False, 'CELERY_IGNORE_RESULT': False, 'CASSANDRA_KEYSPACE': None, 'EMAIL_HOST_PASSWORD': None, 'CELERYMON_LOG_LEVEL': 'INFO', 'CELERY_DISABLE_RATE_LIMITS': False, 'CELERY_TASK_PUBLISH_RETRY_POLICY': {'interval_start': 0, 'interval_max': 1, 'max_retries': 3, 'interval_step': 0.2}, 'CELERY_SECURITY_KEY': None, 'CELERY_MONGODB_BACKEND_SETTINGS': None, 'CELERY_DEFAULT_RATE_LIMIT': None, 'CELERYBEAT_SYNC_EVERY': 0, 'CELERY_EVENT_QUEUE_TTL': None, 'CELERYD_POOL_PUTLOCKS': True, 'CELERY_TASK_SERIALIZER': 'pickle', 'CELERYD_WORKER_LOST_WAIT': 10.0, 'CASSANDRA_SERVERS': None, 'CELERYD_POOL_RESTARTS': False, 'CELERY_TASK_PUBLISH_RETRY': True, 'CELERY_ENABLE_UTC': True, 'CELERY_SEND_EVENTS': False, 'BROKER_CONNECTION_MAX_RETRIES': 100, 'CELERYD_LOG_FILE': None, 'CELERYD_FORCE_EXECV': False, 'CELERY_CHORD_PROPAGATES': True, 'CELERYD_AUTOSCALER': 'celery.worker.autoscale:Autoscaler', 'CELERYD_STATE_DB': None, 'CELERY_ROUTES': None, 'CELERYD_TIMER': None, 'ADMINS': (), 'BROKER_HEARTBEAT_CHECKRATE': 3.0, 'CELERY_ACCEPT_CONTENT': ['json', 'pickle', 'msgpack', 'yaml'], 'BROKER_LOGIN_METHOD': None, 'BROKER_CONNECTION_RETRY': True, 'CELERY_TIMEZONE': None, 'CASSANDRA_WRITE_CONSISTENCY': None, 'CELERYBEAT_MAX_LOOP_INTERVAL': 0, 'CELERYD_LOG_LEVEL': 'WARN', 'CELERY_REDIRECT_STDOUTS': True, 'BROKER_POOL_LIMIT': 10, 'CELERY_SECURITY_CERT_STORE': None, 'CELERYD_CONSUMER': 'celery.worker.consumer:Consumer', 'CELERY_INCLUDE': (), 'CELERYD_MAX_TASKS_PER_CHILD': None, 'CELERYD_LOG_FORMAT': '[%(asctime)s: %(levelname)s/%(processName)s] %(message)s', 'CELERY_ANNOTATIONS': None, 'CELERY_MESSAGE_COMPRESSION': None, 'CASSANDRA_READ_CONSISTENCY': None, 'EMAIL_USE_SSL': False, 'CELERY_SEND_TASK_ERROR_EMAILS': False, 'CELERY_QUEUES': None, 'CELERY_ACKS_LATE': False, 'CELERYMON_LOG_FORMAT': '[%(asctime)s: %(levelname)s] %(message)s', 'CELERY_TASK_RESULT_EXPIRES': datetime.timedelta(1), 'BROKER_HOST': None, 'EMAIL_PORT': 25, 'BROKER_FAILOVER_STRATEGY': None, 'CELERY_RESULT_BACKEND': 'rpc://', 'CELERY_BROADCAST_EXCHANGE': 'celeryctl', 'CELERYBEAT_LOG_FILE': None, 'CELERYBEAT_SCHEDULE': {}, 'CELERY_RESULT_DBURI': None, 'CELERY_DEFAULT_DELIVERY_MODE': 2, 'CELERYBEAT_LOG_LEVEL': 'INFO', 'CASSANDRA_COLUMN_FAMILY': None, 'EMAIL_HOST_USER': None}



via Chebli Mohamed

Python: Combine Multiline to Singleline

I have input file with data:

2015-06-05 16:22:10 Payload-Line-1

Payload-Line-2 

2015-06-05 16:22:11 Payload-Line-1

Payload-Line-2

Payload-Line-3

2015-06-05 16:22:12 Payload-Line-1

I try to make out file like:

2015-06-05 16:22:10 Payload-Line-1
Payload-Line-2 

2015-06-05 16:22:11 Payload-Line-1
Payload-Line-2
Payload-Line-3

2015-06-05 16:22:12 Payload-Line-1

This is multiline start from same regex \d{1,4}\-\d{1,2}\-\d{1,2}, but i can not do this

Any python experts can help me?



via Chebli Mohamed

using pandas to read in a single column CSV

I am attempting to read in a single column CSV using the read_csv() function, but for some reason whenever I attempt to, i get an error:

ValueError: 'Message' is not in list

Here is the code that i am using (just a warning, I did not write all of this. I am inheriting this script from someone else and i have to maintain it.)

def get_data(fp, encoding='utf-8', columns=['Message']):
    """Get the columns from the raw data file provided."""
    if 'csv' in fp.split('.')[-1]:
        data = pd.read_csv(fp, usecols=columns,
                           converters={'Message':
                                       lambda x: unicode(x,
                                                     encoding,
                                                     errors='ignore')})

I am unsure why i am having this issue, and any help or pointing me in the right direction would be appreciated.



via Chebli Mohamed