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>
                            主站蜘蛛池模板: 首页-恒温恒湿试验箱_恒温恒湿箱_高低温试验箱_高低温交变湿热试验箱_苏州正合 | SDI车窗夹力测试仪-KEMKRAFT方向盘测试仪-上海爱泽工业设备有限公司 | 辽宁资质代办_辽宁建筑资质办理_辽宁建筑资质延期升级_辽宁中杭资质代办 | 紧急泄压人孔_防爆阻火器_阻火呼吸阀[河北宏泽石化] | 合肥网带炉_安徽箱式炉_钟罩炉-合肥品炙装备科技有限公司 | 生态板-实木生态板-生态板厂家-源木原作生态板品牌-深圳市方舟木业有限公司 | 不锈钢法兰-碳钢法兰-法兰盘生产加工厂家-[鼎捷峰]-不锈钢法兰-碳钢法兰-法兰盘生产加工厂家-[鼎捷峰] | 半容积式换热器_北京浮动盘管换热器厂家|北京亿丰上达 | 不锈钢散热器,冷却翅片管散热器厂家-无锡市烨晟化工装备科技有限公司 | 电动打包机_气动打包机_钢带捆扎机_废纸打包机_手动捆扎机 | 视频直播 -摄影摄像-视频拍摄-直播分发 | 不锈钢拉手厂家|浴室门拉手厂家|江门市蓬江区金志翔五金制品有限公司 | PC构件-PC预制构件-构件设计-建筑预制构件-PC构件厂-锦萧新材料科技(浙江)股份有限公司 | 过跨车_过跨电瓶车_过跨转运车_横移电动平车_厂区转运车_无轨转运车 | 海外仓系统|国际货代系统|退货换标系统|WMS仓储系统|海豚云 | 山西3A认证|太原AAA信用认证|投标AAA信用证书-山西AAA企业信用评级网 | 重庆轻质隔墙板-重庆安吉升科技有限公司 | 英超直播_英超免费在线高清直播_英超视频在线观看无插件-24直播网 | 进口试验机价格-进口生物材料试验机-西安卡夫曼测控技术有限公司 | 广州展台特装搭建商|特装展位设计搭建|展会特装搭建|特装展台制作设计|展览特装公司 | Eiafans.com_环评爱好者 环评网|环评论坛|环评报告公示网|竣工环保验收公示网|环保验收报告公示网|环保自主验收公示|环评公示网|环保公示网|注册环评工程师|环境影响评价|环评师|规划环评|环评报告|环评考试网|环评论坛 - Powered by Discuz! | 奥运星-汽车性能网评-提供个性化汽车资讯 | 减速机_上海宜嘉减速机| 挤奶设备过滤纸,牛奶过滤纸,挤奶机过滤袋-济南蓝贝尔工贸有限公司 | 单电机制砂机,BHS制砂机,制沙机设备,制砂机价格-正升制砂机厂家 单级/双级旋片式真空泵厂家,2xz旋片真空泵-浙江台州求精真空泵有限公司 | 橡胶接头_橡胶软接头_可曲挠橡胶接头-巩义市创伟机械制造有限公司 | 宿松新闻网 宿松网|宿松在线|宿松门户|安徽宿松(直管县)|宿松新闻综合网站|宿松官方新闻发布 | 线材成型机,线材折弯机,线材成型机厂家,贝朗自动化设备有限公司1 | 代理记账_免费注册公司_营业执照代办_资质代办-【乐财汇】 | 水热合成反应釜-防爆高压消解罐-西安常仪仪器设备有限公司 | 磁粉制动器|张力控制器|气胀轴|伺服纠偏控制器整套厂家--台灵机电官网 | 房车价格_依维柯/大通/东风御风/福特全顺/江铃图片_云梯搬家车厂家-程力专用汽车股份有限公司 | 安平县鑫川金属丝网制品有限公司,声屏障,高速声屏障,百叶孔声屏障,大弧形声屏障,凹凸穿孔声屏障,铁路声屏障,顶部弧形声屏障,玻璃钢吸音板 | 冷藏车厂家|冷藏车价格|小型冷藏车|散装饲料车厂家|程力专用汽车股份有限公司销售十二分公司 | 成都顶呱呱信息技术有限公司-贷款_个人贷款_银行贷款在线申请 - 成都贷款公司 | 魔方网-培训咨询服务平台| 出国劳务公司_正规派遣公司[严海] | 生产自动包装秤_颗粒包装秤_肥料包装秤等包装机械-郑州鑫晟重工科技有限公司 | 运动木地板厂家,篮球场木地板品牌,体育场馆木地板安装 - 欧氏运动地板 | 昆明网络公司|云南网络公司|昆明网站建设公司|昆明网页设计|云南网站制作|新媒体运营公司|APP开发|小程序研发|尽在昆明奥远科技有限公司 | 脱硝喷枪-氨水喷枪-尿素喷枪-河北思凯淋环保科技有限公司 |