Home > Net >  converting a python list with multiple elements
converting a python list with multiple elements

Time:08-27

Good morning everyone,

basically all i want is to convert my List that i recieve into an array with float values. However the RecieveList is not that nice to convert. But more to that below:

I have a List with 1000 values that i recieve after some measurements are done. It is Build up like below:

['42.007870;0.000000;1.000000;2.000000;3.000000;4.000000;5.000000;6.000000;7.000000;8.000000\r\n9.000000;10.000000;11.000000;12.000000;13.000000;14.000000;15.000000;16.000000;17.000000;18.000000\r\n19.000000;20.000000;21.000000;22.000000;23.000000;24.000000;25.000000;26.000000;27.000000;28.000000\r\n29.000000;30.000000;31.000000;32.000000;33.000000;34.000000;35.000000;36.000000;37.000000;38.000000\r\n39.000000;40.000000;41.000000;42.000000;43.000000;44.000000;45.000000;46.000000;47.000000;48.000000\r\n49.000000;50.000000;51.000000;52.000000;53.000000;54.000000;55.000000;56.000000;57.000000;58.000000\r\n59.000000;60.000000;61.000000;62.000000;63.000000;64.000000;65.000000;66.000000;67.000000;68.000000\r\n69.000000;70.000000;71.000000;72.000000;73.000000;74.000000;75.000000;76.000000;77.000000;78.000000\r\n79.000000;80.000000;81.000000;82.000000;83.000000;84.000000;85.000000;86.000000;87.000000;88.000000\r\n89.000000;90.000000;91.000000;92.000000;93.000000;94.000000;95.000000;96.000000;97.000000;98.000000\r\n', '99.000000;100.000000;101.000000;102.000000;103.000000;104.000000;105.000000;106.000000;107.000000;108.000000\r\n109.000000;110.000000;111.000000;112.000000;113.000000;114.000000;115.000000;116.000000;117.000000;118.000000\r\n119.000000;120.000000;121.000000;122.000000;123.000000;124.000000;125.000000;126.000000;127.000000;128.000000\r\n129.000000;130.000000;131.000000;132.000000;133.000000;134.000000;135.000000;136.000000;137.000000;138.000000\r\n139.000000;140.000000;141.000000;142.000000;143.000000;144.000000;145.000000;146.000000;147.000000;148.000000\r\n149.000000;150.000000;151.000000;152.000000;153.000000;154.000000;155.000000;156.000000;157.000000;158.000000\r\n159.000000;160.000000;161.000000;162.000000;163.000000;164.000000;165.000000;166.000000;167.000000;168.000000\r\n169.000000;170.000000;171.000000;172.000000;173.000000;174.000000;175.000000;176.000000;177.000000;178.000000\r\n179.000000;180.000000;181.000000;182.000000;183.000000;184.000000;185.000000;186.000000;187.000000;188.000000\r\n189.000000;190.000000;191.000000;192.000000;193.000000;194.000000;195.000000;196.000000;197.000000;198.000000\r\n', '199.000000;200.000000;201.000000;202.000000;203.000000;204.000000;205.000000;206.000000;207.000000;208.000000\r\n209.000000;210.000000;211.000000;212.000000;213.000000;214.000000;215.000000;216.000000;217.000000;218.000000\r\n219.000000;220.000000;221.000000;222.000000;223.000000;224.000000;225.000000;226.000000;227.000000;228.000000\r\n229.000000;230.000000;231.000000;232.000000;233.000000;234.000000;235.000000;236.000000;237.000000;238.000000\r\n239.000000;240.000000;241.000000;242.000000;243.000000;244.000000;245.000000;246.000000;247.000000;248.000000\r\n249.000000;250.000000;251.000000;252.000000;253.000000;254.000000;255.000000;256.000000;257.000000;258.000000\r\n259.000000;260.000000;261.000000;262.000000;263.000000;264.000000;265.000000;266.000000;267.000000;268.000000\r\n269.000000;270.000000;271.000000;272.000000;273.000000;274.000000;275.000000;276.000000;277.000000;278.000000\r\n279.000000;280.000000;281.000000;282.000000;283.000000;284.000000;285.000000;286.000000;287.000000;288.000000\r\n289.000000;290.000000;291.000000;292.000000;293.000000;294.000000;295.000000;296.000000;297.000000;298.000000\r\n', '299.000000;300.000000;301.000000;302.000000;303.000000;304.000000;305.000000;306.000000;307.000000;308.000000\r\n309.000000;310.000000;311.000000;312.000000;313.000000;314.000000;315.000000;316.000000;317.000000;318.000000\r\n319.000000;320.000000;321.000000;322.000000;323.000000;324.000000;325.000000;326.000000;327.000000;328.000000\r\n329.000000;330.000000;331.000000;332.000000;333.000000;334.000000;335.000000;336.000000;337.000000;338.000000\r\n339.000000;340.000000;341.000000;342.000000;343.000000;344.000000;345.000000;346.000000;347.000000;348.000000\r\n349.000000;350.000000;351.000000;352.000000;353.000000;354.000000;355.000000;356.000000;357.000000;358.000000\r\n359.000000;360.000000;361.000000;362.000000;363.000000;364.000000;365.000000;366.000000;367.000000;368.000000\r\n369.000000;370.000000;371.000000;372.000000;373.000000;374.000000;375.000000;376.000000;377.000000;378.000000\r\n379.000000;380.000000;381.000000;382.000000;383.000000;384.000000;385.000000;386.000000;387.000000;388.000000\r\n389.000000;390.000000;391.000000;392.000000;393.000000;394.000000;395.000000;396.000000;397.000000;398.000000\r\n', '399.000000;400.000000;401.000000;402.000000;403.000000;403.413879;399.493317;392.945496;387.709930;383.786652\r\n378.548645;373.308441;368.066010;362.823303;357.578400;353.647766;347.083954;343.150818;337.899078;332.647064\r\n327.392822;323.454803;318.198151;312.939270;307.680145;302.418793;297.155243;293.209839;286.623474;282.675598\r\n276.084808;273.456757;268.183929;262.910858;257.635529;255.002670;248.402679;244.445068;239.164932;235.204895\r\n229.920395;225.959900;221.997253;218.034409;212.745132;208.779877;206.138702;200.846878;196.877106;192.909103\r\n188.936996;186.292877;180.994186;177.021484;174.374817;170.399811;166.424622;163.775467;159.797989;157.148499\r\n153.168747;150.518921;146.538818;143.886719;141.232529;141.238495;135.925842;133.273209;129.288330;126.633415\r\n123.976410;121.321220;118.663948;116.006538;113.348999;110.691330;109.363663;106.705795;105.377930;102.717903\r\n101.389847;98.729614;96.069260;94.740868;92.080307;90.749756;89.421097;86.758316;85.429459;85.432632\r\n82.769653;81.438637;80.109512;77.444313;76.114990;74.783638;73.452225;73.454796;72.123322;70.791771\r\n', '69.460159;68.128479;66.796730;65.464920;64.133034;62.801086;62.803123;61.469158;61.471130;60.139046\r\n58.806900;58.808739;57.474571;56.142288;56.143990;54.811646;54.813278;53.478912;53.480484;52.148003\r\n52.149506;52.151009;52.152512;52.154015;52.155518;52.157021;52.158524;52.160027;52.161530;49.491020\r\n49.492393;49.493759;48.161079;46.826378;46.827614;46.828850;46.830086;45.495316;45.496487;45.497658\r\n45.498825;45.499992;45.501163;44.166328;44.167431;44.168533;44.169636;44.170738;44.171841;42.838890\r\n44.173981;44.175079;44.176186;42.843235;44.178322;42.845375;42.846409;42.847443;42.848480;42.849518\r\n42.850552;42.851585;42.852623;41.517654;42.854630;41.519661;41.520630;41.521599;42.858570;42.859604\r\n42.860641;41.525673;42.862648;41.527679;42.864651;41.529682;41.530651;41.531620;42.868591;41.533623\r\n42.870598;41.535629;42.872604;41.537636;41.538605;41.539574;41.540543;41.541512;42.878483;41.543514\r\n42.880486;41.545517;41.546486;41.547455;41.548424;41.549393;42.886368;41.551399;42.888374;41.553406\r\n', '41.554375;41.555344;41.556313;41.557281;41.558250;41.559219;41.560188;41.561157;41.562126;41.563095\r\n41.564064;42.901035;41.566067;41.567036;41.568005;41.568974;41.569942;41.570911;41.571880;41.572849\r\n42.909821;41.574852;41.575821;41.576790;41.577759;41.578728;41.579697;41.580666;41.581635;41.582603\r\n41.583572;41.584541;41.585510;41.586479;41.587448;41.588417;41.589386;41.590355;41.591324;41.592293\r\n41.593262;41.594231;41.595200;41.596169;41.597137;41.598106;41.599075;41.600044;41.601013;41.601982\r\n41.602951;41.603920;41.604889;40.269855;41.606762;41.607731;41.608700;41.609669;41.610638;41.611607\r\n41.612576;40.277542;41.614449;41.615417;41.616386;41.617355;41.618324;41.619293;40.284256;41.621162\r\n41.622131;40.287094;40.287998;40.288902;40.289803;40.290703;40.291607;41.628513;40.293480;40.294380\r\n40.295280;40.296185;40.297089;40.297989;40.298889;41.635796;40.300762;41.637669;40.302635;40.303535\r\n40.304436;40.305340;40.306244;40.307144;40.308044;40.308949;41.645855;40.310822;38.975716;40.312557\r\n', '40.313461;40.314362;40.315262;40.316166;40.317070;40.317970;40.318871;40.319775;40.320679;40.321579\r\n40.322479;40.323383;40.324287;40.325188;38.990086;40.326927;40.327827;40.328728;40.329632;40.330536\r\n40.331436;40.332336;40.333241;40.334145;38.999039;40.335880;40.336784;40.337685;40.338585;40.339489\r\n40.340393;40.341293;40.342194;40.343098;40.344002;40.344902;40.345802;40.346706;40.347610;40.348511\r\n39.013409;40.350250;39.015144;39.015984;39.016815;40.353657;40.354561;40.355461;40.356361;40.357265\r\n40.358170;40.359070;39.023968;40.360809;39.025703;40.362545;40.363449;40.364349;39.029247;39.030083\r\n39.030918;40.367760;39.032654;40.369495;40.370399;40.371300;39.036198;40.373039;39.037933;40.374775\r\n39.039673;39.040508;39.041344;40.378181;39.043083;40.379921;40.380821;39.045723;39.046555;39.047394\r\n39.048225;39.049065;39.049896;40.386738;39.051636;39.052471;39.053307;39.054142;39.054977;39.055813\r\n39.056648;40.393486;39.058388;39.059219;39.060059;39.060890;39.061729;39.062561;39.063400;39.064232\r\n', '39.065071;39.065903;40.402744;39.067642;39.068478;39.069313;39.070148;39.070984;39.071819;40.408661\r\n39.073555;39.074394;39.075226;39.076065;39.076897;40.413738;39.078636;40.415474;39.080376;40.417213\r\n39.082111;39.082947;39.083782;40.420624;40.421524;40.422424;39.087326;40.424164;39.089062;39.089897\r\n39.090733;39.091568;39.092403;39.093239;39.094074;39.094910;39.095745;40.432587;39.097481;39.098320\r\n39.099152;39.099991;39.100822;40.437664;39.102562;39.103397;39.104233;39.105068;39.105904;39.106739\r\n39.107574;39.108410;39.109245;39.110081;40.446922;40.447823;39.112720;39.113556;39.114391;39.115227\r\n39.116062;39.116898;39.117733;39.118568;39.119404;40.456245;40.457146;39.122044;39.122879;39.123714\r\n39.124550;40.461388;40.462292;39.127190;40.464027;40.464931;40.465836;39.130730;39.131569;39.132401\r\n39.133240;39.134071;40.470913;39.135811;40.472649;39.137550;39.138382;40.475224;39.140121;39.140957\r\n40.477798;40.478699;39.143597;40.480438;40.481339;39.146236;40.483078;39.147972;39.148811;39.149643\r\n', '39.150482;39.151314;40.488155;40.489059;39.153954;39.154793;39.155624;39.156464;40.493301;39.158199\r\n39.159035;39.159870;39.160706;39.161541;39.162376;39.163212;39.164047;39.164883;39.165718;39.166553\r\n39.167389;39.168224;39.169060;39.169895;39.170731;39.171566;40.508408;39.173302;39.174141;39.174973\r\n40.511814;39.176712;39.177547;39.178383;40.515221;39.180122;39.180954;39.181793;39.182625;39.183464\r\n39.184296;39.185135;39.185966;39.186806;40.523643;39.188541;40.525383;39.190277;39.191116;39.191948\r\n39.192787;39.193619;39.194458;40.531296;40.532196;39.197098;39.197929;39.198769;39.199600;39.200439\r\n39.201271;39.202110;40.538948;39.203846;40.540688;39.205582;39.206421;39.207253;39.208092;39.208923\r\n39.209763;39.210594;39.211433;39.212265;39.213104;39.213936;39.214775;39.215607;39.216446;39.217278\r\n39.218117;39.218948;40.555790;39.220688;39.221523;39.222359;39.223194;39.224030;39.224865;39.225700\r\n39.226536;39.227371;39.228207;39.229042;39.229877;39.230713;39.231548;39.232384;40.569221;39.234123\r\n']

i know it is kind of a mess and i can't change the input array but let's do a quick coding to make it more understandable:

for i in range(10):
    TestList1.append(recieveList[i].split('\r\n'))

after that code, the array is quite more understandable:

[['40.913563;0.000000;1.000000;2.000000;3.000000;4.000000;5.000000;6.000000;7.000000;8.000000', '9.000000;10.000000;11.000000;12.000000;13.000000;14.000000;15.000000;16.000000;17.000000;18.000000', '19.000000;20.000000;21.000000;22.000000;23.000000;24.000000;25.000000;26.000000;27.000000;28.000000', '29.000000;30.000000;31.000000;32.000000;33.000000;34.000000;35.000000;36.000000;37.000000;38.000000', '39.000000;40.000000;41.000000;42.000000;43.000000;44.000000;45.000000;46.000000;47.000000;48.000000', '49.000000;50.000000;51.000000;52.000000;53.000000;54.000000;55.000000;56.000000;57.000000;58.000000', '59.000000;60.000000;61.000000;62.000000;63.000000;64.000000;65.000000;66.000000;67.000000;68.000000', '69.000000;70.000000;71.000000;72.000000;73.000000;74.000000;75.000000;76.000000;77.000000;78.000000', '79.000000;80.000000;81.000000;82.000000;83.000000;84.000000;85.000000;86.000000;87.000000;88.000000', '89.000000;90.000000;91.000000;92.000000;93.000000;94.000000;95.000000;96.000000;97.000000;98.000000', ''], ['99.000000;100.000000;101.000000;102.000000;103.000000;104.000000;105.000000;106.000000;107.000000;108.000000', '109.000000;110.000000;111.000000;112.000000;113.000000;114.000000;115.000000;116.000000;117.000000;118.000000', '119.000000;120.000000;121.000000;122.000000;123.000000;124.000000;125.000000;126.000000;127.000000;128.000000', '129.000000;130.000000;131.000000;132.000000;133.000000;134.000000;135.000000;136.000000;137.000000;138.000000', '139.000000;140.000000;141.000000;142.000000;143.000000;144.000000;145.000000;146.000000;147.000000;148.000000', '149.000000;150.000000;151.000000;152.000000;153.000000;154.000000;155.000000;156.000000;157.000000;158.000000', '159.000000;160.000000;161.000000;162.000000;163.000000;164.000000;165.000000;166.000000;167.000000;168.000000', '169.000000;170.000000;171.000000;172.000000;173.000000;174.000000;175.000000;176.000000;177.000000;178.000000', '179.000000;180.000000;181.000000;182.000000;183.000000;184.000000;185.000000;186.000000;187.000000;188.000000', '189.000000;190.000000;191.000000;192.000000;193.000000;194.000000;195.000000;196.000000;197.000000;198.000000', ''], ['199.000000;200.000000;201.000000;202.000000;203.000000;204.000000;205.000000;206.000000;207.000000;208.000000', '209.000000;210.000000;211.000000;212.000000;213.000000;214.000000;215.000000;216.000000;217.000000;218.000000', '219.000000;220.000000;221.000000;222.000000;223.000000;224.000000;225.000000;226.000000;227.000000;228.000000', '229.000000;230.000000;231.000000;232.000000;233.000000;234.000000;235.000000;236.000000;237.000000;238.000000', '239.000000;240.000000;241.000000;242.000000;243.000000;244.000000;245.000000;246.000000;247.000000;248.000000', '249.000000;250.000000;251.000000;252.000000;253.000000;254.000000;255.000000;256.000000;257.000000;258.000000', '259.000000;260.000000;261.000000;262.000000;263.000000;264.000000;265.000000;266.000000;267.000000;268.000000', '269.000000;270.000000;271.000000;272.000000;273.000000;274.000000;275.000000;276.000000;277.000000;278.000000', '279.000000;280.000000;281.000000;282.000000;283.000000;284.000000;285.000000;286.000000;287.000000;288.000000', '289.000000;290.000000;291.000000;292.000000;293.000000;294.000000;295.000000;296.000000;297.000000;298.000000', ''], ['299.000000;300.000000;301.000000;302.000000;303.000000;304.000000;305.000000;306.000000;307.000000;308.000000', '309.000000;310.000000;311.000000;312.000000;313.000000;314.000000;315.000000;316.000000;317.000000;318.000000', '319.000000;320.000000;321.000000;322.000000;323.000000;324.000000;325.000000;326.000000;327.000000;328.000000', '329.000000;330.000000;331.000000;332.000000;333.000000;334.000000;335.000000;336.000000;337.000000;338.000000', '339.000000;340.000000;341.000000;342.000000;343.000000;344.000000;345.000000;346.000000;347.000000;348.000000', '349.000000;350.000000;351.000000;352.000000;353.000000;354.000000;355.000000;356.000000;357.000000;358.000000', '359.000000;360.000000;361.000000;362.000000;363.000000;364.000000;365.000000;366.000000;367.000000;368.000000', '369.000000;370.000000;371.000000;372.000000;373.000000;374.000000;375.000000;376.000000;377.000000;378.000000', '379.000000;380.000000;381.000000;382.000000;383.000000;384.000000;385.000000;386.000000;387.000000;388.000000', '389.000000;390.000000;391.000000;392.000000;393.000000;394.000000;395.000000;396.000000;397.000000;398.000000', ''], ['399.000000;400.000000;401.000000;402.000000;403.000000;404.000000;405.000000;406.000000;407.000000;408.000000', '409.000000;410.000000;411.000000;412.000000;413.000000;414.000000;415.000000;416.000000;417.000000;418.000000', '419.000000;420.000000;421.000000;422.000000;423.000000;424.000000;425.000000;426.000000;427.000000;428.000000', '429.000000;430.000000;431.000000;432.000000;433.000000;434.000000;435.000000;436.000000;437.000000;438.000000', '439.000000;440.000000;441.000000;442.000000;443.000000;444.000000;445.000000;446.000000;447.000000;448.000000', '449.000000;450.000000;451.000000;452.000000;453.000000;454.000000;45500000;473.000000;474.000000;475.000000;476.000000;477.000000;478.000000', '479.000000;475.956238;469.433105;464.216370;457.688751;452.469452;445.937347;440.713562;435.487549;428.950684', '423.720184;417.178833;411.945770;405.397949;400.162384;393.612000;388.371918;381.817078;376.574432;371.329590', ''], ['364.766052;359.518677;352.952606;347.700714;341.130127;335.873749;330.617096;325.358246;318.780670;314.837708', '308.253754;302.987915;297.721802;292.453461;287.182922;281.912109;276.637146;271.361877;266.086365;262.130981', '256.851105;251.570969;247.610931;242.326416;238.365936;233.079010;229.116089;225.151031;219.859528;215.894012', '211.926331;206.630280;202.662140;200.016129;194.717514;190.744873;188.098267;184.125290;180.150162;176.172882', '172.195404;169.545914;165.566147;161.586182;158.936172;156.284073;153.629883;154.965988;148.323242;143.010330', '140.355469;137.698532;135.043411;132.386200;129.730820;127.073341;124.415733;121.756042;120.430267;116.438278', '113.778183;112.450058;109.789764;108.461433;105.800941;103.138367;101.809708;99.146927;97.818069;96.487183', '93.824142;92.495010;91.163864;89.832657;87.169273;85.837860;85.840431;83.174896;81.843285;80.511604', '79.179855;77.848038;76.516159;75.184219;73.850250;72.518173;71.186020;71.187866;69.853699;68.521416', '67.189072;65.854706;65.856277;63.187790;64.525230;64.526733;64.528236;64.529739;64.531242;61.860737', ''], ['60.528057;59.193356;59.194592;57.859825;57.860996;56.526161;56.527264;55.194317;55.195354;53.860386', '53.861355;53.862324;52.527290;52.528194;52.529099;52.530003;52.530907;51.195805;51.196640;49.861469', '49.862236;49.863003;49.863770;48.528534;49.865238;48.530003;48.530704;48.531406;48.532108;48.532810', '47.197506;47.198139;47.198772;47.199406;48.536045;47.200741;47.201374;47.202007;45.864685;45.865253', '47.203777;45.866455;45.867023;45.867592;45.868160;45.868729;45.869297;44.533859;45.870365;45.870934', '45.871502;45.872070;45.872639;45.873207;45.873775;45.874344;45.874912;44.539474;44.539974;44.540474', '44.540974;44.541473;44.541973;44.542473;44.542973;44.543472;44.543972;44.544472;44.544971;44.545471', '44.545971;44.546471;44.546970;44.547470;44.547970;44.548470;44.548969;44.549469;44.549969;44.550468', '45.886974;44.551537;44.552036;44.552536;44.553036;44.553535;44.554035;44.554535;44.555035;44.555534', '44.556034;44.556534;45.893040;44.557602;44.558102;44.558601;44.559101;44.559601;44.560101;44.560600', ''], ['44.561100;44.561600;44.562099;44.562599;44.563099;44.563599;44.564098;44.564598;44.565098;44.565598', '44.566097;43.230595;44.567032;44.567532;44.568031;44.568531;44.569031;43.233528;43.233963;43.234398', '43.234833;43.235268;44.571705;44.572205;44.572704;44.573204;43.237701;43.238136;43.238571;43.239006', '43.239441;44.575878;43.240376;43.240810;43.241245;43.241680;43.242115;43.242550;43.242985;43.243420', '43.243855;43.244289;43.244724;43.245159;43.245594;43.246029;43.246464;43.246899;41.911327;41.911694', '43.248066;43.248501;43.248936;43.249371;43.249805;41.914234;41.914600;41.914967;41.915333;43.251705', '41.916134;43.252506;43.252941;41.917370;41.917736;41.918102;41.918468;41.918835;41.919201;41.919567', '41.919933;41.920300;41.920666;41.921032;41.921398;41.921764;41.922131;41.922497;41.922863;41.923229', '41.923595;43.259968;41.924397;41.924763;41.925129;43.261501;41.925930;41.926296;41.926662;41.927029', '41.927395;41.927761;41.928127;41.928493;41.928860;41.929226;41.929592;41.929958;41.930325;41.930691', ''], ['41.931057;41.931423;41.931789;41.932156;41.932522;41.932888;41.933254;41.933620;41.933987;41.934353', '41.934719;41.935085;41.935452;41.935818;41.936184;41.936550;41.936916;41.937283;41.937649;41.938015', '41.938381;41.938747;41.939114;41.939480;41.939846;41.940212;41.940578;41.940945;41.941311;41.941677', '41.942043;41.942410;41.942776;41.943142;41.943508;41.943874;41.944241;41.944607;41.944973;41.945339', '41.945705;41.946072;41.946438;41.946804;41.947170;41.947536;41.947903;41.948269;41.948635;43.285007', '41.949436;43.285809;41.950237;41.950603;41.950970;41.951336;41.951702;41.952068;41.952435;41.952801', '41.953167;41.953533;41.953899;41.954266;41.954632;41.954998;41.955364;41.955730;41.956097;41.956463', '41.956829;41.957195;41.957561;41.957928;41.958294;41.958660;41.959026;41.959393;41.959759;41.960125', '41.960491;41.960857;41.961224;41.961590;41.961956;41.962322;41.962688;43.299061;41.963490;41.963856', '41.964222;41.964588;41.964954;41.965321;41.965687;41.966053;41.966419;41.966785;41.967152;41.967518', ''], ['41.967884;41.968250;41.968616;41.968983;41.969349;41.969715;41.970081;41.970448;41.970814;41.971180', '41.971546;41.971912;41.972279;41.972645;41.973011;41.973377;41.973743;41.974110;41.974476;41.974842', '41.975208;41.975574;41.975941;41.976307;41.976673;41.977039;41.977406;41.977772;41.978138;41.978504', '41.978870;41.979237;41.979603;41.979969;41.980335;41.980701;41.981068;41.981434;41.981800;41.982166', '41.982533;41.982899;41.983265;41.983631;41.983997;41.984364;41.984730;41.985096;41.985462;41.985828', '41.9861']]

so now i have basically 10 "slave"-lists in one "master"-list. With each "slave"-list holding 100 measurements. That are seperated strings with 10 measurements.

kind of like:

[[string0.1,string0.2,string0.3 ..],[string1.1, string1.2 ...], ...]

so far so good. now i tried to use a code like this:

result = ''.join(''.join(l) for l in TestList1)
TestList2=result.split(';')

which was kinda what i wanted, however every 10th and 11th value are fused together. as you can see below:

['42.369370', '0.000000', '1.000000', '2.000000', '3.000000', '4.000000', '5.000000', '6.000000', '7.000000', '8.0000009.000000', '10.000000', '11.000000', '12.000000', '13.000000', '14.000000', 
'15.000000', '16.000000', '17.000000', '18.00000019.000000', '20.000000', '21.000000', '22.000000', '23.000000', '24.000000', '25.000000', '26.000000', '27.000000', '28.00000029.000000', '30.000000', '31.000000', '32.000000', '33.000000', '34.000000', '35.000000', '36.000000', '37.000000', '38.00000039.000000', '40.000000', '41.000000', '42.000000', '43.000000', '44.000000', '45.000000', '46.000000', '47.000000', '48.00000049.000000', '50.000000', '51.000000', '52.000000', '53.000000', '54.000000', '55.000000', '56.000000', '57.000000', '58.00000059.000000', '60.000000', '61.000000', '62.000000', '63.000000', '64.000000', '65.000000', '66.000000', '67.000000', '68.00000069.000000', '70.000000', '71.000000', '72.000000', '73.000000', '74.000000', '75.000000', '76.000000', '77.000000', '78.00000079.000000', '80.000000', '81.000000', '82.000000', '83.000000', '84.000000', '85.000000', '86.000000', '87.000000', '88.00000089.000000', '90.000000', '91.000000', '92.000000', '93.000000', '94.000000', '95.000000', '96.000000', '97.000000', '98.00000099.000000', '100.000000', '101.000000', '102.000000', '103.000000', '104.000000', '105.000000', '106.000000', '107.000000', '108.000000109.000000', '110.000000', '111.000000', '112.000000', '113.000000', '114.000000', '115.000000', '116.000000', '117.000000', '118.000000119.000000', '120.000000', '121.000000', '122.000000', '123.000000', '124.000000', '125.000000', '126.000000', '127.000000', '128.000000129.000000', '130.000000', '131.000000', '132.000000', '133.000000', '134.000000', '135.000000', '136.000000', '137.000000', '138.000000139.000000', '140.000000', '141.000000', '142.000000', '143.000000', '144.000000', '145.000000', '146.000000', '147.000000', '148.000000149.000000', '150.000000', '151.000000', '152.000000', '153.000000', '154.000000', '155.000000', '156.000000', '157.000000', '158.000000159.000000', '160.000000', '161.000000', '162.000000', '163.000000', '164.000000', '165.000000', '166.000000', '167.000000', '168.000000169.000000', '170.000000', '171.000000', '172.000000', '173.000000', '174.000000', '175.000000', '176.000000', '177.000000', '178.000000179.000000', '180.000000', '181.000000', '182.000000', '183.000000', '184.000000', '185.000000', '186.000000', '187.000000', '188.000000189.000000', '190.000000', '191.000000', '192.000000', '193.000000', '194.000000', '195.000000', '196.000000', '197.000000', '198.000000199.000000', '200.000000', '201.000000', '202.000000', '203.000000', '204.000000', '205.000000', '206.000000', '207.000000', '208.000000209.000000', '210.000000', '211.000000', '212.000000', '213.000000', '214.000000', '215.000000', '216.000000', '217.000000', '218.000000219.000000', '220.000000', '221.000000', '222.000000', '223.000000', '224.000000', '225.000000', '226.000000', '227.000000', '228.000000229.000000', '230.000000', '231.000000', '232.000000', '233.000000', '234.000000', '235.000000', '236.000000', '237.000000', '238.000000239.000000', '240.000000', '241.000000', '242.000000', '243.000000', '244.000000', '245.000000', '246.000000', '247.000000', '248.000000249.000000', '250.000000', '251.000000', '252.000000', '253.000000', '254.000000', '255.000000', '256.000000', '257.000000', '258.000000259.000000', '260.000000', '261.000000', '262.000000', '263.000000', '264.000000', 
'265.000000', '266.000000', '267.000000', '268.000000269.000000', '270.000000', '271.000000', '272.000000', '273.000000', '274.000000', '275.000000', '276.000000', '277.000000', '278.000000279.000000', '280.000000', '281.000000', '282.000000', '283.000000', '284.000000', '285.000000', '286.000000', '287.000000', '288.000000289.000000', '290.000000', '291.000000', '292.000000', '293.000000', '294.000000', '295.000000', '296.000000', '297.000000', '298.000000299.000000', '300.000000', '301.000000', '302.000000', '303.000000', '304.000000', '305.000000', '306.000000', '307.000000', '308.000000309.000000', '310.000000', '311.000000', '312.000000', '313.000000', '314.000000', '315.000000', '316.000000', '317.000000', '318.000000319.000000', '320.000000', '321.000000', '322.000000', '323.000000', '324.000000', '325.000000', '326.000000', '324.518158', '320.580444315.326080', '312.706360', '308.766113', '304.825684', '300.885040', '295.623810', '291.680756', '287.737518', '283.792114', '279.846497275.898773', '271.950806', '266.680328', '262.729980', '258.779419', '254.826691', '250.873779', '246.920670', '245.610077', '239.010071233.730133', '229.772263', '225.812225', '221.852005', '217.891571', '213.929001', '209.966217', '206.003250', '202.038116', '198.070847195.429611', '191.463943', '187.494186', '183.526184', '179.554062', '176.909943', '172.937500', '168.964859', '166.318253', '162.345276159.696396', '155.721130', '153.071915', '149.094360', '146.444809', '143.793182', '139.813217', '137.163193', '134.511093', '131.856903131.862869', '127.880356', '125.227783', '121.242981', '118.588127', '115.931183', '113.276062', '110.618858', '109.293617', '106.636208103.978668', '102.653091', '101.325500', '97.335594', '96.007729', '93.347702', '92.019646', '89.359421', '88.031158', '85.37073585.374367', '82.713814', '81.383263', '78.722504', '77.391754', '76.062897', '76.066071', '73.403091', '73.406128', '70.74301969.411865', '68.080658', '66.751328', '66.754028', '65.422684', '64.091270', '62.759792', '61.428246', '61.430683', '60.09906860.101440', '57.435707', '57.437946', '56.106133', '56.108303', '54.776421', ]

duo to that fusion of some values i can not convert it like:

TestList2=[float(i) for i in TestList2]

I hope i could explain my problem and my progress so far. Surely my path isn't the best, as i'm still learning Python. So if anyyone has a completly other fix, feel free to share it with me :)

Have a good Day

Dominik

CodePudding user response:

Since the line breaks are the same as semicolons, we can first strip the line breaks at the end, then replace remaining line breaks with semicolons. Then a simple str.split(';') will do.

data = ['1.00;2.00\r\n3.00;4.00\r\n', '5.00;6.00\r\n7.00;8.00\r\n']
output = []
for item in data:
    output.append(item.strip().replace('\r\n', ';').split(';'))
print(output)

# Or a one-liner:
print([item.strip().replace('\r\n', ';').split(';') for item in data])

Output:

[['1.00', '2.00', '3.00', '4.00'], ['5.00', '6.00', '7.00', '8.00']]

Then you can convert it into floats:

>>> [[float(v) for v in x] for x in output]
[[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]

CodePudding user response:

Rather than splitting the string, use a regular expression to identify the floating point values within the string.

Like this:

from re import findall
list_ = ['42.007870;0.000000;1.000000;2.000000;3.000000;4.000000;5.000000;6.000000;7.000000;8.000000\r\n9.000000;10.000000;11.000000;12.000000;13.000000;14.000000;15.000000;16.000000;17.000000;18.000000\r\n19.000000;20.000000;21.000000;22.000000;23.000000;24.000000;25.000000;26.000000;27.000000;28.000000\r\n29.000000;30.000000;31.000000;32.000000;33.000000;34.000000;35.000000;36.000000;37.000000;38.000000\r\n39.000000;40.000000;41.000000;42.000000;43.000000;44.000000;45.000000;46.000000;47.000000;48.000000\r\n49.000000;50.000000;51.000000;52.000000;53.000000;54.000000;55.000000;56.000000;57.000000;58.000000\r\n59.000000;60.000000;61.000000;62.000000;63.000000;64.000000;65.000000;66.000000;67.000000;68.000000\r\n69.000000;70.000000;71.000000;72.000000;73.000000;74.000000;75.000000;76.000000;77.000000;78.000000\r\n79.000000;80.000000;81.000000;82.000000;83.000000;84.000000;85.000000;86.000000;87.000000;88.000000\r\n89.000000;90.000000;91.000000;92.000000;93.000000;94.000000;95.000000;96.000000;97.000000;98.000000\r\n', '99.000000;100.000000;101.000000;102.000000;103.000000;104.000000;105.000000;106.000000;107.000000;108.000000\r\n109.000000;110.000000;111.000000;112.000000;113.000000;114.000000;115.000000;116.000000;117.000000;118.000000\r\n119.000000;120.000000;121.000000;122.000000;123.000000;124.000000;125.000000;126.000000;127.000000;128.000000\r\n129.000000;130.000000;131.000000;132.000000;133.000000;134.000000;135.000000;136.000000;137.000000;138.000000\r\n139.000000;140.000000;141.000000;142.000000;143.000000;144.000000;145.000000;146.000000;147.000000;148.000000\r\n149.000000;150.000000;151.000000;152.000000;153.000000;154.000000;155.000000;156.000000;157.000000;158.000000\r\n159.000000;160.000000;161.000000;162.000000;163.000000;164.000000;165.000000;166.000000;167.000000;168.000000\r\n169.000000;170.000000;171.000000;172.000000;173.000000;174.000000;175.000000;176.000000;177.000000;178.000000\r\n179.000000;180.000000;181.000000;182.000000;183.000000;184.000000;185.000000;186.000000;187.000000;188.000000\r\n189.000000;190.000000;191.000000;192.000000;193.000000;194.000000;195.000000;196.000000;197.000000;198.000000\r\n', '199.000000;200.000000;201.000000;202.000000;203.000000;204.000000;205.000000;206.000000;207.000000;208.000000\r\n209.000000;210.000000;211.000000;212.000000;213.000000;214.000000;215.000000;216.000000;217.000000;218.000000\r\n219.000000;220.000000;221.000000;222.000000;223.000000;224.000000;225.000000;226.000000;227.000000;228.000000\r\n229.000000;230.000000;231.000000;232.000000;233.000000;234.000000;235.000000;236.000000;237.000000;238.000000\r\n239.000000;240.000000;241.000000;242.000000;243.000000;244.000000;245.000000;246.000000;247.000000;248.000000\r\n249.000000;250.000000;251.000000;252.000000;253.000000;254.000000;255.000000;256.000000;257.000000;258.000000\r\n259.000000;260.000000;261.000000;262.000000;263.000000;264.000000;265.000000;266.000000;267.000000;268.000000\r\n269.000000;270.000000;271.000000;272.000000;273.000000;274.000000;275.000000;276.000000;277.000000;278.000000\r\n279.000000;280.000000;281.000000;282.000000;283.000000;284.000000;285.000000;286.000000;287.000000;288.000000\r\n289.000000;290.000000;291.000000;292.000000;293.000000;294.000000;295.000000;296.000000;297.000000;298.000000\r\n', '299.000000;300.000000;301.000000;302.000000;303.000000;304.000000;305.000000;306.000000;307.000000;308.000000\r\n309.000000;310.000000;311.000000;312.000000;313.000000;314.000000;315.000000;316.000000;317.000000;318.000000\r\n319.000000;320.000000;321.000000;322.000000;323.000000;324.000000;325.000000;326.000000;327.000000;328.000000\r\n329.000000;330.000000;331.000000;332.000000;333.000000;334.000000;335.000000;336.000000;337.000000;338.000000\r\n339.000000;340.000000;341.000000;342.000000;343.000000;344.000000;345.000000;346.000000;347.000000;348.000000\r\n349.000000;350.000000;351.000000;352.000000;353.000000;354.000000;355.000000;356.000000;357.000000;358.000000\r\n359.000000;360.000000;361.000000;362.000000;363.000000;364.000000;365.000000;366.000000;367.000000;368.000000\r\n369.000000;370.000000;371.000000;372.000000;373.000000;374.000000;375.000000;376.000000;377.000000;378.000000\r\n379.000000;380.000000;381.000000;382.000000;383.000000;384.000000;385.000000;386.000000;387.000000;388.000000\r\n389.000000;390.000000;391.000000;392.000000;393.000000;394.000000;395.000000;396.000000;397.000000;398.000000\r\n', '399.000000;400.000000;401.000000;402.000000;403.000000;403.413879;399.493317;392.945496;387.709930;383.786652\r\n378.548645;373.308441;368.066010;362.823303;357.578400;353.647766;347.083954;343.150818;337.899078;332.647064\r\n327.392822;323.454803;318.198151;312.939270;307.680145;302.418793;297.155243;293.209839;286.623474;282.675598\r\n276.084808;273.456757;268.183929;262.910858;257.635529;255.002670;248.402679;244.445068;239.164932;235.204895\r\n229.920395;225.959900;221.997253;218.034409;212.745132;208.779877;206.138702;200.846878;196.877106;192.909103\r\n188.936996;186.292877;180.994186;177.021484;174.374817;170.399811;166.424622;163.775467;159.797989;157.148499\r\n153.168747;150.518921;146.538818;143.886719;141.232529;141.238495;135.925842;133.273209;129.288330;126.633415\r\n123.976410;121.321220;118.663948;116.006538;113.348999;110.691330;109.363663;106.705795;105.377930;102.717903\r\n101.389847;98.729614;96.069260;94.740868;92.080307;90.749756;89.421097;86.758316;85.429459;85.432632\r\n82.769653;81.438637;80.109512;77.444313;76.114990;74.783638;73.452225;73.454796;72.123322;70.791771\r\n', '69.460159;68.128479;66.796730;65.464920;64.133034;62.801086;62.803123;61.469158;61.471130;60.139046\r\n58.806900;58.808739;57.474571;56.142288;56.143990;54.811646;54.813278;53.478912;53.480484;52.148003\r\n52.149506;52.151009;52.152512;52.154015;52.155518;52.157021;52.158524;52.160027;52.161530;49.491020\r\n49.492393;49.493759;48.161079;46.826378;46.827614;46.828850;46.830086;45.495316;45.496487;45.497658\r\n45.498825;45.499992;45.501163;44.166328;44.167431;44.168533;44.169636;44.170738;44.171841;42.838890\r\n44.173981;44.175079;44.176186;42.843235;44.178322;42.845375;42.846409;42.847443;42.848480;42.849518\r\n42.850552;42.851585;42.852623;41.517654;42.854630;41.519661;41.520630;41.521599;42.858570;42.859604\r\n42.860641;41.525673;42.862648;41.527679;42.864651;41.529682;41.530651;41.531620;42.868591;41.533623\r\n42.870598;41.535629;42.872604;41.537636;41.538605;41.539574;41.540543;41.541512;42.878483;41.543514\r\n42.880486;41.545517;41.546486;41.547455;41.548424;41.549393;42.886368;41.551399;42.888374;41.553406\r\n', '41.554375;41.555344;41.556313;41.557281;41.558250;41.559219;41.560188;41.561157;41.562126;41.563095\r\n41.564064;42.901035;41.566067;41.567036;41.568005;41.568974;41.569942;41.570911;41.571880;41.572849\r\n42.909821;41.574852;41.575821;41.576790;41.577759;41.578728;41.579697;41.580666;41.581635;41.582603\r\n41.583572;41.584541;41.585510;41.586479;41.587448;41.588417;41.589386;41.590355;41.591324;41.592293\r\n41.593262;41.594231;41.595200;41.596169;41.597137;41.598106;41.599075;41.600044;41.601013;41.601982\r\n41.602951;41.603920;41.604889;40.269855;41.606762;41.607731;41.608700;41.609669;41.610638;41.611607\r\n41.612576;40.277542;41.614449;41.615417;41.616386;41.617355;41.618324;41.619293;40.284256;41.621162\r\n41.622131;40.287094;40.287998;40.288902;40.289803;40.290703;40.291607;41.628513;40.293480;40.294380\r\n40.295280;40.296185;40.297089;40.297989;40.298889;41.635796;40.300762;41.637669;40.302635;40.303535\r\n40.304436;40.305340;40.306244;40.307144;40.308044;40.308949;41.645855;40.310822;38.975716;40.312557\r\n', '40.313461;40.314362;40.315262;40.316166;40.317070;40.317970;40.318871;40.319775;40.320679;40.321579\r\n40.322479;40.323383;40.324287;40.325188;38.990086;40.326927;40.327827;40.328728;40.329632;40.330536\r\n40.331436;40.332336;40.333241;40.334145;38.999039;40.335880;40.336784;40.337685;40.338585;40.339489\r\n40.340393;40.341293;40.342194;40.343098;40.344002;40.344902;40.345802;40.346706;40.347610;40.348511\r\n39.013409;40.350250;39.015144;39.015984;39.016815;40.353657;40.354561;40.355461;40.356361;40.357265\r\n40.358170;40.359070;39.023968;40.360809;39.025703;40.362545;40.363449;40.364349;39.029247;39.030083\r\n39.030918;40.367760;39.032654;40.369495;40.370399;40.371300;39.036198;40.373039;39.037933;40.374775\r\n39.039673;39.040508;39.041344;40.378181;39.043083;40.379921;40.380821;39.045723;39.046555;39.047394\r\n39.048225;39.049065;39.049896;40.386738;39.051636;39.052471;39.053307;39.054142;39.054977;39.055813\r\n39.056648;40.393486;39.058388;39.059219;39.060059;39.060890;39.061729;39.062561;39.063400;39.064232\r\n', '39.065071;39.065903;40.402744;39.067642;39.068478;39.069313;39.070148;39.070984;39.071819;40.408661\r\n39.073555;39.074394;39.075226;39.076065;39.076897;40.413738;39.078636;40.415474;39.080376;40.417213\r\n39.082111;39.082947;39.083782;40.420624;40.421524;40.422424;39.087326;40.424164;39.089062;39.089897\r\n39.090733;39.091568;39.092403;39.093239;39.094074;39.094910;39.095745;40.432587;39.097481;39.098320\r\n39.099152;39.099991;39.100822;40.437664;39.102562;39.103397;39.104233;39.105068;39.105904;39.106739\r\n39.107574;39.108410;39.109245;39.110081;40.446922;40.447823;39.112720;39.113556;39.114391;39.115227\r\n39.116062;39.116898;39.117733;39.118568;39.119404;40.456245;40.457146;39.122044;39.122879;39.123714\r\n39.124550;40.461388;40.462292;39.127190;40.464027;40.464931;40.465836;39.130730;39.131569;39.132401\r\n39.133240;39.134071;40.470913;39.135811;40.472649;39.137550;39.138382;40.475224;39.140121;39.140957\r\n40.477798;40.478699;39.143597;40.480438;40.481339;39.146236;40.483078;39.147972;39.148811;39.149643\r\n', '39.150482;39.151314;40.488155;40.489059;39.153954;39.154793;39.155624;39.156464;40.493301;39.158199\r\n39.159035;39.159870;39.160706;39.161541;39.162376;39.163212;39.164047;39.164883;39.165718;39.166553\r\n39.167389;39.168224;39.169060;39.169895;39.170731;39.171566;40.508408;39.173302;39.174141;39.174973\r\n40.511814;39.176712;39.177547;39.178383;40.515221;39.180122;39.180954;39.181793;39.182625;39.183464\r\n39.184296;39.185135;39.185966;39.186806;40.523643;39.188541;40.525383;39.190277;39.191116;39.191948\r\n39.192787;39.193619;39.194458;40.531296;40.532196;39.197098;39.197929;39.198769;39.199600;39.200439\r\n39.201271;39.202110;40.538948;39.203846;40.540688;39.205582;39.206421;39.207253;39.208092;39.208923\r\n39.209763;39.210594;39.211433;39.212265;39.213104;39.213936;39.214775;39.215607;39.216446;39.217278\r\n39.218117;39.218948;40.555790;39.220688;39.221523;39.222359;39.223194;39.224030;39.224865;39.225700\r\n39.226536;39.227371;39.228207;39.229042;39.229877;39.230713;39.231548;39.232384;40.569221;39.234123\r\n']

print(list(map(float, findall('(\d \.\d )', list_[0]))))

Output:

[42.00787, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0, 71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0, 80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0, 90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0]
  • Related