私はPythonを使ってテスト用のデータを生成しています。ファイルへの出力のランダム化
私はすべてのプロセスがかなりうまくいくはずですが、私はこのコードを持っています。
私は何をできるようにしたいと思いますが、ユーザー情報2,3,4とline4,5,6に移入されdef get_lines():
line1 = "Document Header - Once per document"
line2 = "\nDocument Information - Once per document"
line3 = "\nDocument Information 2 - Once per document"
line4 = "\nUser information 1"
line5 = "\nUser Information 1"
line6 = "\nUser Information 1"
line7 = "\nDocument Footer - Once per document"
return line1 + line2 + line3 + line4 + line5 + line6 + line7
このような何か:
line1 = "Document Header - Once per document"
line2 = "\nDocument Information - Once per document"
line3 = "\nDocument Information 2 - Once per document"
line4 = "\nUser information 1"
line5 = "\nUser Information 1"
line6 = "\nUser Information 1"
line4 = "\nUser information 2"
line5 = "\nUser Information 2"
line6 = "\nUser Information 2"
line4 = "\nUser information 3"
line5 = "\nUser Information 3"
line6 = "\nUser Information 3"
line7 = "\nDocument Footer - Once per document"
しかし、それはランダム化されている、つまり私が言い10ファイルがほしい、いくつかはいくつかのユーザー情報のいくつか2いくつか3などなど...
私は必要なものを生産するための一貫した方法を見つけるのに苦労しています。
ありがとうございます。
EDIT:追加サンプルメッセージ:ORC OBRとOBXは、すべてのUIDの
MSH|^~\&||||||||201705301105||ORM^O01|4960855009|P|2.5||NE|AL||||
PID|1||^^^^HOSPITALNO~^^^^NHSNO||Hendry^John||190203130000|F||||||||||||||
PV1|1||G2D||||||||||||||||||||||||||||||||||||||||||||||||
ORC|NW|2017053019783377||19783377|||1^^^201705304500^^R||^^^201705
OBR|1|2017053019783377||1019|||2017053011045|201705301045||Test001||||||||||
OBX|1|ST|2017053019783377||2017053019783377|||||||||||||||
SPM|1|||||||||||||||||||||||||||||
なぜ、すべて別々の変数? –
行のリストを作成します。 'random'モジュールを使用してください –
@JonClementsはい、4,5,6行目はリンクされますが、各行はそれ自身の別個の変数です。 – Lloyd