Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 972753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:10:24+00:00 2026-05-16T03:10:24+00:00

I have a csv file like 120 column by 4500 row. I read the

  • 0

I have a csv file like 120 column by 4500 row.
I read the field “customer name” in the first column, first row.
I then look fot this field in a second cvs file containing the “customer name , and customer ID”
I write a new cvs file with “customer name”, customer ID”, and all the rest of the 119 colunm.and continue until end of first file.

This is working, but I have special character everywhere in the first two csv files.
And I dont want to have ‘Montr\xe9al-Nord’ instead of Montréal-Nord
or ‘Val\xe9rie Lamarche’ instead of ‘Valérie Lamarche’ in the resulting csv file.

here is a test code exemple:

# -*- coding: utf-8 -*-


import  types
import  wx
import sys
import os, os.path
import win32file
import shutil
import string
import  wx.lib.dialogs
import re
import EmailAttache
import StringIO,csv
import time
import csv

outputfile=open(os.path.join(u"c:\\transales","Resultat-second_contact_act.csv"), "wb")

resultat = csv.writer (outputfile )

def Writefile ( info1, info2 ):
    print info1, info2
    resultat.writerow( [ `info1`,`info2` ,`line[1]`,`line[2]`,`line[3]`,`line[4]`,`line[5]`,`line[6]`,`line[7]`,`line[8]`,`line[9]`,`line[10]`,`line[11]`,`line[12]`,`line[13]`,`line[14]`,`line[15]`,`line[16]`,`line[17]` ] )


data = open(os.path.join(u"c:\\transales","SECONDARY_CONTACTS.CSV"),"rb")
data2 = open(os.path.join(u"c:\\transales","AccountID+ContactID.csv"),"rb")

source1 = csv.reader(data)
source2 = csv.reader(data2)



for line in source1:
    name= line[0]
    data2.seek(0)
    for line2 in source2:
        if line[0] == line2[0]:    
            Writefile(line[0],line2[1])
            break

outputfile.close()

Any help ?

regards, francois

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:10:24+00:00Added an answer on May 16, 2026 at 3:10 am

    The problem is in this line:

    resultat.writerow( [ `info1`,`info2` ,`line[1]`,`line[2]`,`line[3]`,`line[4]`,`line[5]`,`line[6]`,`line[7]`,`line[8]`,`line[9]`,`line[10]`,`line[11]`,`line[12]`,`line[13]`,`line[14]`,`line[15]`,`line[16]`,`line[17]` ] )
    

    Wrapping an expression in “back-ticks” aka “grave accents” is an old-fashioned and deprecated way of saying repr(expression).

    Please consider the following:

    >>> s = "Montréal"
    >>> print s
    Montréal
    >>> print repr(s)
    'Montr\xe9al'
    >>> ord(s[5])
    233
    >>> hex(233)
    '0xe9'
    >>> s == "Montr\xe9al"
    True
    >>> `s` == repr(s)
    True
    

    The offending (in 3 ways) line should be simply replaced by

    resultat.writerow([info1, info2] + [line[1:18]]) # WRONG (sorry!)
    resultat.writerow([info1, info2] + line[1:18]) # RIGHT
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV file formatted just like this: name,color,tasty,qty apple,red,true,3 orange,orange,false,4 pear,greenish-yellowish,true,1 As
I have some lines in a CSV file like this: 1000001234,Account Name,0,0,3,711.32,0,0,18,629.64,22,340.96,COD,20,000.00,Some string,Some string
I have my CSV file imported as such: records = FasterCSV.read(path, :headers => true,
I have a .csv file like this: stack2@domain.example,2009-11-27 01:05:47.893000000,domain.example,127.0.0.1 overflow@domain2.example,2009-11-27 00:58:29.793000000,domain2.example,255.255.255.0 overflow@domain2.example,2009-11-27 00:58:29.646465785,domain2.example,256.255.255.0 ...
Ok, I have a csv file like this: 14 ; 1234,56 ; 10203 ;
I have a csv file which looks like this $lines[0] = text, with commas,
So I have a CSV file that looks like this: 12345, Here is some
I have a .csv file that is frequently updated (about 20 to 30 times
I have a CSV file that holds about 200,000 - 300,000 records. Most of
I have a csv file of the format: 270291014011 ED HARDY - TRUE TO

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.