0
私は、テキストファイルに値を挿入できるプログラムを作成しており、効率的な方法を考え出すのに問題があります。目標は、Z軸上のすべての変更の前にM220コマンドを持つことです。このコマンドは、全体のプログラムにいくつのZの変更があるかに基づいています。現在私が持っているアイデアは、次のとおりです。gcode挿入用のより効率的なテキストエディタ
はTake the text file, and transfer it into an array
Read through each character to see if there is a Z
Count the total amount of Z's
Start at the beginning of the array
Create a new array that copies the first one
If a Z value is found, insert a line before it with the M220 command
Overwrite the text file with the new array
これは私が20MbのオーバーTXTファイルを扱うことがしようと思って、特に以来、私には非常に非効率です。これを行うには明らかに良い方法がありますか?
20MBは実際には大きすぎません。ファイルの塊をメモリに読み込んでZをスキャンし、変更されたチャンクを一時ファイルに書き込んだら、元のファイルを削除して一時ファイルの名前を元のファイル名に戻すことができます。 – JJF