V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
rebeccaMyKid
V2EX  ›  问与答

用 Excel 将 xlsx 转 csv 后读出来变成了一行

  •  
  •   rebeccaMyKid · 2017-07-31 16:22:56 +08:00 · 1751 次点击
    这是一个创建于 2666 天前的主题,其中的信息可能已经有所发展或是发生改变。

    windows 传来一个 xlsx,然后用 mac Excel 转 csv,python 用f.readlines()读出来,变成了一个只有一个元素的 list,很迷,求指点。

    ['\xef\xbb\xbfrecipient-name,ship-address-1,ship-address-2,ship-city,ship-state,ship-postal-code,ship-country,ship-phone-number\rTaylor Robertson,1223 BILLIE JOHNSON LN,,GARLAND,TX,75044-5235,US,202-555-0142\rRebecca Alison Baker,921 BARTON SPRINGS RD,,AUSTIN,TX,78704-1147,US,202-555-0173\rRobert E. Sullivan,318 SUMMIT VIEW AVE SE,,SALEM,OR,97306-3001,US,202-555-0157\rTara Leap,822 KOSOTO TRL,,MEDFORD LAKES,NJ,08055-1103,US,202-555-0149\rAmber george,1291 PATRICIA DR,,CLARKSVILLE,TN,37040-7346,US,202-555-0188\rDana Fitzpatrick,23 GOLD RD,,KETCHIKAN,AK,99901-9628,US,202-555-0174\rTANIA VARGAS,1811 BASSETT ST APT 416,,DENVER,CO,80202-1014,US,202-555-0148\rLindsey N Flores,139 PERRAUD DR,,FOLSOM,CA,95630-2959,US,202-555-0129\rTata de Leon,124 CARLL DR,,BAY SHORE,NEW YORK,11706-6204,US,202-555-0158\rClara Hundley,15199 TIDEWATER TRL,TAPPAHANNOCK VIRGINIA,TAPPAHANNOCK,VIRGINIA,22560-5219,US,202-555-0163\rCarol Harmon,152 S PROSPECT AVE,,PARK RIDGE,IL,60068-5349,US,202-555-0174\rIRINA GRIBUN,273 LOHNES ROAD,,FRAMINGHAM,MA,1701,US,202-555-0188\rXin Zhang,918 DURLANE CT,,SUNNYVALE,CA,94087-4948,US,202-555-0139\rDave McFate,562 LOWER LICK CREEK RD,,LINDEN,TN,37096-5319,US,202-555-0184\rZachary Adam Kuntz,526 JONAGOLD CIR,,MECHANICSBURG,PENNSYLVANIA,17055-6496,US,202-555-0152\rKathryn Zetzer,423 NE 72ND ST APT E424,,SEATTLE,WASHINGTON,98115-5408,US,202-555-0114\rGREGG A HUESKE,1010 North Shore Drive,,HASTINGS,NE,68901,US,202-555-0188\rMarlo Kleckley,2167 RED PHEASANT DR,,VACAVILLE,CA,95687-7750,US,202-555-0183\rJoshua Stack,95 SANDHILL CT,,BRUSSELS,WI,54204-9719,US,202-555-0117\rBrenda Groseclose,1014 BARRACUDA AVE NE,,AVON,MN,56310-8675,US,202-555-0166\rAngel osorio,1053 OAKWOOD AVE APT 9,,LOS ANGELES,CA,90004-3526,US,202-555-0171\rAnthony Garlett,22 HOLLY DR,,SEEKONK,MA,02771-4614,US,202-555-0139\rtom kendris,85 GREENWAY DR,,STATEN ISLAND,NY,10301-3366,US,202-555-0170\rKimberly A Harbison,515 BELFONTE ST,,RUSSELL,KY,41169-1322,US,202-555-0171\rCasey Kent,1911 Highway 80 east,,Calhoun,Louisiana,71225,US,202-555-0175\rJILL N LITTRELL,892 TYLERTON CIR,,GRAYSLAKE,IL,60030-1197,US,202-555-0191\rCari Adams,7380 AUTUMN CT,,AVON,INDIANA,46123-7403,US,202-555-0123']

    2 条回复    2017-08-01 08:49:05 +08:00
    Mac
        1
    Mac  
       2017-07-31 17:03:10 +08:00
    \r 就是回车啊
    thedog
        2
    thedog  
       2017-08-01 08:49:05 +08:00 via iPhone
    mac 下换行分隔符为\r,readlines 按\n 分隔读进来的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2954 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 12:34 · PVG 20:34 · LAX 04:34 · JFK 07:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.