标签: text

如何使用Perl拆分文本文件并将其存储到2d数组中?

230215 01/16/2000 57533 "" 0 1045403 "" ? 0 0 217623

230215 01/18/2000 77659 "" 0 1045403 "" ? 0 0 217624

230215 01/25/2000 76583 "" 0 1045403 "" ? 0 0 217625

230215 01/29/2000 58082 "" 0 1045403 "" ? 0 0 217626

230216 01/14/2000 50020 "" 0 1045403 "" ? 0 0 217627

230216 01/18/2000 66444 "" 0 1045403 "" ? 0 0 217628

230216 01/19/2000 51330 "" 0 1045403 "" ? 0 0 217629
Run Code Online (Sandbox Code Playgroud)

所有字段都用空格分隔,我需要将它存储到二维数组中.实际上有500万行像这样.例如,我想将它存储到像$ arr [7] …

arrays perl text

-4
推荐指数
2
解决办法
1万
查看次数

什么不在txt文件中表示?

我正在使用pandas打开一个txt文件,并且文件中应该有一个列中断 \t而是.

我在这样的文件中阅读:

df=pd.read_csv(r'file.txt')
Run Code Online (Sandbox Code Playgroud)

数据框如下所示:

1           Band 1\t 0.428944\t0.843916\t0.689923\t0                    
2           Band 2\t-0.000000\t0.689320\t0.513170\t0                   
3           Band 3\t 0.336438\t0.743478\t0.592622\t0                    
4           Band 4\t 0.313259\t0.678561\t0.525667\t0                     
5           Band 5\t 0.374522\t0.746828\t0.583513\t0
Run Code Online (Sandbox Code Playgroud)

我希望它看起来像这样:

1           Band 1   0.428944  0.843916  0.689923                     
2           Band 2  -0.000000  0.689320  0.513170                  
3           Band 3   0.336438  0.743478  0.592622                    
4           Band 4   0.313259  0.678561  0.525667                    
5           Band 5   0.374522  0.746828  0.583513
Run Code Online (Sandbox Code Playgroud)

我是新手在python中使用txt文件,我是否可能需要设置某种分隔符?

运用 print(repr(open(r'D:\Sheyenne\Statistics\NDVI_allotment\Text\A_Annex2.txt').read(42)))回报:

'\n\n     Band 1\t 0.428944\t0.843916\t0.689923\t
Run Code Online (Sandbox Code Playgroud)

编辑:

我发布的原始数据帧是简化的,实际上有更多的数据列.

`print(repr(open(r'D:\Sheyenne\Statistics\NDVI_allotment\Text\A_Annex2.csv').read(500)))
Run Code Online (Sandbox Code Playgroud)

收益:

'\nBasic Stats\t      Min\t     Max\t    Mean\t   Stdev\t  Num\tEigenvalue\n     Band 1\t 0.428944\t0.843916\t0.689923\t0.052534\t    1\t  0.229509\n …
Run Code Online (Sandbox Code Playgroud)

python text pandas

-4
推荐指数
1
解决办法
1878
查看次数

来自文本文件的2d数组c#

我有一个看起来像这样的文本文件

1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 …
Run Code Online (Sandbox Code Playgroud)

c# arrays text 2d file

-5
推荐指数
2
解决办法
3万
查看次数

检测文本是否为非英语

检测文本(特别是Instagram评论)是非英语的最准确方法是什么?我很乐意使用任何高级语言,例如Python,PHP等.

$ sudo pip2 install guess_language
>>> from guess_language import guessLanguage
>>> guessLanguage('la vita e bella')
'UNKNOWN'
>>> guessLanguage('today is a good day')
'UNKNOWN'
>>> guessLanguage('????????????????(???)')
'ja'
Run Code Online (Sandbox Code Playgroud)

$ sudo apt-get install php5.6-mbstring

      if(strlen($comment->text) == mb_strlen($comment->text, 'utf-8')) {
         echo '- '.$comment->text."\n";
    }
Run Code Online (Sandbox Code Playgroud)

我得到许多不是英文的英文字符:例子:

- Khoda be khanevadehashon sabr bede tahamol konan
- Akhey...
- Eshghi
- K
- :-)
- Ey khodaa
- ...
- @samaneaghazamani1990 vaaaaay khoda chejoori payam dadan?
- :(
- Elahiiiii
- May Allah please with …
Run Code Online (Sandbox Code Playgroud)

php python text nlp language-detection

-5
推荐指数
1
解决办法
817
查看次数

每120,000行拆分文本文件?

所以我有一个文本文件,我需要每120,000分割一次,当它在第120,000行分割时,我需要将其余部分分成另一个文本文件.关于这个人的任何想法?

.net c# text

-6
推荐指数
1
解决办法
453
查看次数

我的jQuery代码有什么问题?给出错误,它不是一个功能

我在Wordpress中使用它,所以我试图将$符号更改为jQuery,但这也不起作用.这是脚本:

<script>
    jQuery().ready(function($) {
       var name = $('#user-submitted-posts-wrapper').data('name');
       if ( name != '') $('.usp-title input').eq(0).value(name);
    });
    </script>
Run Code Online (Sandbox Code Playgroud)

我收到错误:

 $(...).eq(...).value is not a function
Run Code Online (Sandbox Code Playgroud)

可能是什么问题?我试图用我得到的文本预填充输入字段.输入字段具有name属性,没有class或ID属性.那更好用吗?我究竟做错了什么?

wordpress jquery text input

-7
推荐指数
2
解决办法
115
查看次数

未在此范围内声明(C++中的数组)

我是C++编程的初学者我有一个文本文件,其中有100万个素数用空格分隔.我想把它们放在一个int数组primes []中.以下是我写的代码:

int main()
{
    ifstream infile;
    infile.open("C:/Users/DELL/Desktop/primes1.txt");

    //check for error
    if(infile.fail()){cerr<<"Error Opening File"<<endl;
    exit(1);}
    int i=0;
    primes = new int[1000001];
    while(i != infile.eof()){
        infile>>primes[i];
        i++;
    }

    cout<<  primes[4]  <<endl;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我构建并运行时,它会出现以下错误:

"错误:'primes'未在此范围内声明"

这是什么解决方案?

c++ arrays error-handling text file

-8
推荐指数
2
解决办法
454
查看次数

为什么这个基本的python程序不起作用?

那么程序应该检查它是否在电子邮件旁边看到"确定"并且它是否在另一个txt文件中吐出电子邮件.

输入txt文件:

.......ng0@gmail.com,ok
.......ad@live.com,fail
.......12@live.com,fail
.......5w@live.com,fail
.......np@gmail.com,ok
.......an@live.com,fail
.......40@excite.com,fail
.......g1@gmail.com,ok
Run Code Online (Sandbox Code Playgroud)

python代码是:

readEmails = open("C:\\Users\\Greg\\Desktop\\rewriteEmails.txt","r")
writeEmails = open("C:\\Users\\Greg\\Desktop\\OutputEmails.txt","w")

for line in readEmails:
    subbed = line[-3:]
    if subbed == "ok":
        split = line.split(",")
        writeEmails.write(split[0])
        print("Email Added")
    else:
        print("Error")
Run Code Online (Sandbox Code Playgroud)

该程序似乎总是转到if语句的else部分.我有点大脑放屁; 我很想你的建议.

python email text organization

-8
推荐指数
1
解决办法
109
查看次数

标签 统计

text ×8

arrays ×3

python ×3

c# ×2

file ×2

.net ×1

2d ×1

c++ ×1

email ×1

error-handling ×1

input ×1

jquery ×1

language-detection ×1

nlp ×1

organization ×1

pandas ×1

perl ×1

php ×1

wordpress ×1