久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" id='PYl8B'><tfoot id='PYl8B'></tfoot><dl id='PYl8B'><fieldset id='PYl8B'></fieldset></dl></div>
                            主站蜘蛛池模板: 国产精品亚洲成在人线 | 国产成人精品一区二 | 91精品国产综合久久久久 | 91在线视频播放 | 91精品国产91久久久久久密臀 | 日韩一二三区视频 | 欧美一区二区三区久久精品 | 亚洲精品电影 | 成人a在线观看 | 激情国产视频 | 人人鲁人人莫人人爱精品 | 在线观看免费国产 | 91资源在线 | 国产精品国产成人国产三级 | 午夜噜噜噜 | 日本不卡视频在线播放 | 亚洲国产精品久久久 | 欧美一区二区在线视频 | 久久精品视频99 | 欧美性区 | 日韩免费三级 | 成人性视频免费网站 | 91网在线观看 | 天天综合国产 | 久久久国产精品网站 | 亚洲精品第一页 | 亚洲欧洲一区二区 | 国产精品一区二区av | 99re6在线 | 午夜精品一区二区三区在线视 | 国产精品一区二区在线 | 亚洲天堂免费在线 | 国产精品久久久久一区二区三区 | 亚洲欧洲成人 | 毛片一区二区三区 | 久久久久久国产精品mv | 老外黄色一级片 | 亚洲精品久久久久久久久久吃药 | 国产精品一区在线 | 久久久免费电影 | 韩国av电影网 |