如何使用特定格式的熊猫从文本文件读取数据?

时间:2018-12-31 03:05:42

标签: python pandas

我有一个文本文件,其中包含如下数据。

20/12/2018 
This is the test text. 

22/12/2018
* 21/12/2018 
This is a test text where the text is written on later than the actual date.

现在让我们说一下,以上数据和日期都在文本文件(text.txt)中。我需要一种读取数据并将其放在熊猫数据框中的方法。我想将它们读入列,

日期文本DateOfWritten

日期将采用实际值,该日期应为文本的实际日期。例如, 日期应为21/22/2018。并且22/12/2018应该是DateOfWritten

预期输出应为: enter image description here

预先感谢。

1 个答案:

答案 0 :(得分:0)

这可能是一个解决方案

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/js/bootstrap-select.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/css/bootstrap-select.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>

<select class="selectpicker" name = "usertype"   title="User Type"  required="true" data-size="7">
            <option value="0"> test1 </option>
            <option value="2"> test2 </option>
            <option value="4"> test3 r</option>
            <option value="6"> test4 </option>
</select>
 <input name = "first_name"  type="text" placeholder="Name" class="form-control"  required="true" value = "">

 <input name = "last_name"  type="text" placeholder="Name" class="form-control"  required="true" value = "">
相关问题