pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

      <legend id='QhZso'><style id='QhZso'><dir id='QhZso'><q id='QhZso'></q></dir></style></legend>

      1. <tfoot id='QhZso'></tfoot>
        <i id='QhZso'><tr id='QhZso'><dt id='QhZso'><q id='QhZso'><span id='QhZso'><b id='QhZso'><form id='QhZso'><ins id='QhZso'></ins><ul id='QhZso'></ul><sub id='QhZso'></sub></form><legend id='QhZso'></legend><bdo id='QhZso'><pre id='QhZso'><center id='QhZso'></center></pre></bdo></b><th id='QhZso'></th></span></q></dt></tr></i><div class="coysas0" id='QhZso'><tfoot id='QhZso'></tfoot><dl id='QhZso'><fieldset id='QhZso'></fieldset></dl></div>

        <small id='QhZso'></small><noframes id='QhZso'>

          <bdo id='QhZso'></bdo><ul id='QhZso'></ul>
      2. 自動檢測文件中是否存在 CSV 標頭

        Autodetect Presence of CSV Headers in a File(自動檢測文件中是否存在 CSV 標頭)
        • <bdo id='MUeda'></bdo><ul id='MUeda'></ul>

              <tbody id='MUeda'></tbody>

            <small id='MUeda'></small><noframes id='MUeda'>

            <tfoot id='MUeda'></tfoot>
              <legend id='MUeda'><style id='MUeda'><dir id='MUeda'><q id='MUeda'></q></dir></style></legend>
              <i id='MUeda'><tr id='MUeda'><dt id='MUeda'><q id='MUeda'><span id='MUeda'><b id='MUeda'><form id='MUeda'><ins id='MUeda'></ins><ul id='MUeda'></ul><sub id='MUeda'></sub></form><legend id='MUeda'></legend><bdo id='MUeda'><pre id='MUeda'><center id='MUeda'></center></pre></bdo></b><th id='MUeda'></th></span></q></dt></tr></i><div class="wi2qe2c" id='MUeda'><tfoot id='MUeda'></tfoot><dl id='MUeda'><fieldset id='MUeda'></fieldset></dl></div>
                  本文介紹了自動檢測文件中是否存在 CSV 標頭的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  小問題:如何自動檢測 CSV 文件的第一行是否有標題?

                  Short question: How do I automatically detect whether a CSV file has headers in the first row?

                  詳細信息:我編寫了一個小型 CSV 解析引擎,將數據放入我可以作為(大約)內存數據庫訪問的對象中.原始代碼是為了解析具有可預測格式的第三方 CSV 文件而編寫的,但我希望能夠更廣泛地使用此代碼.

                  Details: I've written a small CSV parsing engine that places the data into an object that I can access as (approximately) an in-memory database. The original code was written to parse third-party CSV with a predictable format, but I'd like to be able to use this code more generally.

                  我正在嘗試找出一種可靠的方法來自動檢測 CSV 標頭的存在,以便腳本可以決定是使用 CSV 文件的第一行作為鍵名/列名還是立即開始解析數據.由于我只需要一個布爾測試,我可以在自己檢查 CSV 文件后輕松指定一個參數,但我寧愿不必(去自動化).

                  I'm trying to figure out a reliable way to automatically detect the presence of CSV headers, so the script can decide whether to use the first row of the CSV file as keys / column names or start parsing data immediately. Since all I need is a boolean test, I could easily specify an argument after inspecting the CSV file myself, but I'd rather not have to (go go automation).

                  我想我必須將前 3 個解析為 ?CSV 文件的行并查找某種模式以與標題進行比較.我正在做三個特別糟糕的噩夢,其中:

                  I imagine I'd have to parse the first 3 to ? rows of the CSV file and look for a pattern of some sort to compare against the headers. I'm having nightmares of three particularly bad cases in which:

                  1. 由于某種原因,標題包含數字數據
                  2. 前幾行(或 CSV 的大部分)為空
                  3. 標題和數據看起來太相似,無法區分

                  如果我能得到最佳猜測"并且讓解析器因錯誤而失敗或在無法決定時發出警告,那也沒關系.如果這是在時間或計算方面非常昂貴的事情(并且花費的時間比它應該節省的時間更多),我會很高興地放棄這個想法并回到重要的事情"上.

                  If I can get a "best guess" and have the parser fail with an error or spit out a warning if it can't decide, that's OK. If this is something that's going to be tremendously expensive in terms of time or computation (and take more time than it's supposed to save me) I'll happily scrap the idea and go back to working on "important things".

                  我正在使用 PHP,但這更像是一個算法/計算問題,而不是特定于實現的問題.如果有我可以使用的簡單算法,那就太好了.如果你能指點我一些相關的理論/討論,那也太好了.如果有一個巨大的庫可以進行自然語言處理或 300 種不同的解析,我不感興趣.

                  I'm working with PHP, but this strikes me as more of an algorithmic / computational question than something that's implementation-specific. If there's a simple algorithm I can use, great. If you can point me to some relevant theory / discussion, that'd be great, too. If there's a giant library that does natural language processing or 300 different kinds of parsing, I'm not interested.

                  推薦答案

                  正如其他人所指出的,您無法以 100% 的可靠性做到這一點.然而,在某些情況下,基本正確"是有用的 - 例如,具有 CSV 導入功能的電子表格工具通常會嘗試自己解決這個問題.這里有一些啟發式方法,可以表明第一行不是標題:

                  As others have pointed out, you can't do this with 100% reliability. There are cases where getting it 'mostly right' is useful, however - for example, spreadsheet tools with CSV import functionality often try to figure this out on their own. Here's a few heuristics that would tend to indicate the first line isn't a header:

                  • 第一行的列不是字符串或為空
                  • 第一行的列并非都是唯一的
                  • 第一行似乎包含日期或其他常見數據格式(例如,xx-xx-xx)

                  這篇關于自動檢測文件中是否存在 CSV 標頭的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                    <tbody id='PYl8B'></tbody>

                    <legend id='PYl8B'><style id='PYl8B'><dir id='PYl8B'><q id='PYl8B'></q></dir></style></legend>
                      <tfoot id='PYl8B'></tfoot>
                          • <bdo id='PYl8B'></bdo><ul id='PYl8B'></ul>

                            <small id='PYl8B'></small><noframes id='PYl8B'>

                            <i id='PYl8B'><tr id='PYl8B'><dt id='PYl8B'><q id='PYl8B'><span id='PYl8B'><b id='PYl8B'><form id='PYl8B'><ins id='PYl8B'></ins><ul id='PYl8B'></ul><sub id='PYl8B'></sub></form><legend id='PYl8B'></legend><bdo id='PYl8B'><pre id='PYl8B'><center id='PYl8B'></center></pre></bdo></b><th id='PYl8B'></th></span></q></dt></tr></i><div class="5zn5rf5" id='PYl8B'><tfoot id='PYl8B'></tfoot><dl id='PYl8B'><fieldset id='PYl8B'></fieldset></dl></div>
                            主站蜘蛛池模板: 污水/卧式/潜水/钻井/矿用/大型/小型/泥浆泵,价格,参数,型号,厂家 - 安平县鼎千泵业制造厂 | 气象监测系统_气象传感器_微型气象仪_气象环境监测仪-山东风途物联网 | 杭州网络公司_百度SEO优化-外贸网络推广_抖音小程序开发-杭州乐软科技有限公司 | 球盟会·(中国)官方网站 | 硫化罐_蒸汽硫化罐_大型硫化罐-山东鑫泰鑫智能装备有限公司 | 地磅-电子地磅维修-电子吊秤-汽车衡-无人值守系统-公路治超-鹰牌衡器 | 耐腐蚀泵,耐腐蚀真空泵,玻璃钢真空泵-淄博华舜耐腐蚀真空泵有限公司 | GAST/BRIWATEC/CINCINNATI/KARL-KLEIN/ZIEHL-ABEGG风机|亚喜科技 | 杭州火蝠电商_京东代运营_拼多多全托管代运营【天猫代运营】 | 泉州陶瓷pc砖_园林景观砖厂家_石英砖地铺石价格 _福建暴风石英砖 | 砂尘试验箱_淋雨试验房_冰水冲击试验箱_IPX9K淋雨试验箱_广州岳信试验设备有限公司 | 预制直埋蒸汽保温管-直埋管道-聚氨酯发泡保温管厂家 - 唐山市吉祥保温工贸有限公司 | 东莞市踏板石餐饮管理有限公司_正宗桂林米粉_正宗桂林米粉加盟_桂林米粉加盟费-东莞市棒子桂林米粉 | ge超声波测厚仪-电动涂膜机-电动划格仪-上海洪富 | 旅游规划_旅游策划_乡村旅游规划_景区规划设计_旅游规划设计公司-北京绿道联合旅游规划设计有限公司 | 警用|治安|保安|不锈钢岗亭-售货亭价格-垃圾分类亭-移动厕所厂家-苏州灿宇建材 | 上海公司注册-代理记账-招投标审计-上海昆仑扇财税咨询有限公司 上海冠顶工业设备有限公司-隧道炉,烘箱,UV固化机,涂装设备,高温炉,工业机器人生产厂家 | Magnescale探规,Magnescale磁栅尺,Magnescale传感器,Magnescale测厚仪,Mitutoyo光栅尺,笔式位移传感器-苏州连达精密量仪有限公司 | 金属清洗剂,防锈油,切削液,磨削液-青岛朗力防锈材料有限公司 | 有源电力滤波装置-电力有源滤波器-低压穿排电流互感器|安科瑞 | 中天寰创-内蒙古钢结构厂家|门式刚架|钢结构桁架|钢结构框架|包头钢结构煤棚 | 磁力反应釜,高压釜,实验室反应釜,高温高压反应釜-威海自控反应釜有限公司 | CE认证_FCC认证_CCC认证_MFI认证_UN38.3认证-微测检测 CNAS实验室 | 排烟防火阀-消防排烟风机-正压送风口-厂家-价格-哪家好-德州鑫港旺通风设备有限公司 | 罗茨真空机组,立式无油往复真空泵,2BV水环真空泵-力侨真空科技 | 液氮罐_液氮容器_自增压液氮罐-北京君方科仪科技发展有限公司 | 厌氧反应器,IC厌氧反应器,厌氧三相分离器-山东创博环保科技有限公司 | 煤矿支护网片_矿用勾花菱形网_缝管式_管缝式锚杆-邯郸市永年区志涛工矿配件有限公司 | 骨密度检测仪_骨密度分析仪_骨密度仪_动脉硬化检测仪专业生产厂家【品源医疗】 | 飞扬动力官网-广告公司管理软件,广告公司管理系统,喷绘写真条幅制作管理软件,广告公司ERP系统 | 动力配电箱-不锈钢配电箱-高压开关柜-重庆宇轩机电设备有限公司 聚天冬氨酸,亚氨基二琥珀酸四钠,PASP,IDS - 远联化工 | 废旧物资回收公司_广州废旧设备回收_报废设备物资回收-益美工厂设备回收公司 | 众品地板网-地板品牌招商_地板装修设计_地板门户的首选网络媒体。 | 成都租车_成都租车公司_成都租车网_众行宝 | 飞扬动力官网-广告公司管理软件,广告公司管理系统,喷绘写真条幅制作管理软件,广告公司ERP系统 | 注塑_注塑加工_注塑模具_塑胶模具_注塑加工厂家_深圳环科 | 超声波清洗机-超声波清洗设备定制生产厂家 - 深圳市冠博科技实业有限公司 | 广东机电安装工程_中央空调工程_东莞装饰装修-广东粤标建设有限公司 | 菲希尔FISCHER测厚仪-铁素体检测仪-上海吉馨实业发展有限公司 | 工业PH计|工业ph酸度计|在线PH计价格-合肥卓尔仪器仪表有限公司 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 深圳美安可自动化设备有限公司,喷码机,定制喷码机,二维码喷码机,深圳喷码机,纸箱喷码机,东莞喷码机 UV喷码机,日期喷码机,鸡蛋喷码机,管芯喷码机,管内壁喷码机,喷码机厂家 |