|
|
รบกวนนิดนึงครับ เรื่องกด browse text file แล้วบันทึกลง database รูปแบบช่วงข้อมูลที่คั่นไม่แน่นอนครับ จะมีวิธียังไงบ้าง |
|
|
|
|
|
|
|
คือผมจะทำปุ่มกด browse เพื่อเลือก file csv จากนั้นกดตกลง เพื่อทำการ insert ข้อมูลในนั้นลง database แต่ปัญหาคือผมจะ
explode วิธีใดดีครับ
ตย. ข้อมูลใน textfile
File:,40787-1,Specification:,ASTM SCH40,,,,
No.:(38666 4.90X1080 SS400 C/N54360851
Date:,08-12-11,Product:,Pipe,,,,
Time:,10:01,Coil number:,11018608,,,,
Temperature:,24.9,Size:,1/2'' x 21',,,,
Operator:,QC Operator ,Cross Section Area:,148.85,,,,
Direction:,Tension ,Gage Length:,50.8,,,,
RESULTS DATA,,,,,,,
Name,Peak-FF,Peak-SS,Yield-FF,Yield-SS,Elongation,Young's Modulus,
Calculating point ,-,-,0.00-0.00 mm,0.00-0.00 mm,-,0.00-0.00 kgf,
Accepted range ,0.00-0.00 kgf,0.00-0.00 kgf/sq.mm,0.00-0.00 kgf,0.00-0.00 kgf/sq.mm,0.00-0.00 %,0.00-0.00 kgf/sq.mm,
Sample#1 ,5085,34.16,4777,32.09,46.69,119.46,
,,T.S.,,Y.P,EL%,,
ถ้าเกิดผมจะเอา ข้อมูล 40787-1 , 11018608
38666 , 4.90X1080 ,SS400 ,54360851 (แยกชุดข้อมูลที่ถูกเรียงมาก่อนหน้านี้ ที่ผมทำเป็นตัวสีแดงๆ)
ผมจะต้องเขียนโค้ดยังไงหรอครับ
รบกวนท่านผู้รู้ด้วยนะครับ
ขอบคุณครับ
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-06-12 16:20:01 |
By :
มือสมัครเล่น |
View :
1083 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะใช้การค้นหาคำข้างหน้าครับ เช่น File จากนั้นก็ใช้ substr ว่าจะให้ตัดจากตัวอักษาเท่าไหร่ถึงเท่าไหร่
|
|
|
|
|
Date :
2012-06-12 17:12:46 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code
STS11, ,Sample No.:(38683 3.00X1200 SPHT1 C/N54380021 ),28-Mar-12,14:08:40,C ,0.0828,Si ,0.012,Mn ,0.3594,P ,0.0114,S ,0.0097,Ni ,0.0083,Cr ,0.0121,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0428,V ,0.0048,Pb ,0.0036,Fe ,99.263,Ti ,0.0034,Nb ,0
STS11, ,Sample No.:(38702 3.00X1200 SPHT1 C/N54380011 ),28-Mar-12,14:12:05,C ,0.0927,Si ,0.006,Mn ,0.4082,P ,0.0117,S ,0.0092,Ni ,0.0088,Cr ,0.014,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0392,V ,0.0051,Pb ,0.0036,Fe ,99.211,Ti ,0.0036,Nb ,0
STS11, ,Sample No.:(38727 3.00X1200 SPHT1 C/N54360031 ),28-Mar-12,14:16:39,C ,0.1021,Si ,0.0074,Mn ,0.4162,P ,0.0085,S ,0.0107,Ni ,0.0099,Cr ,0.0154,Mo ,0.0007,Cu ,0,Co ,0.1863,Al ,0.0523,V ,0.0041,Pb ,0.0036,Fe ,99.179,Ti ,0.0039,Nb ,0
STS11, ,Sample No.:(38629 3.50X1100 SS400 C/N54460451 ),28-Mar-12,14:20:01,C ,0.1155,Si ,0.006,Mn ,0.4482,P ,0.0077,S ,0.0075,Ni ,0.0086,Cr ,0.0155,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0534,V ,0.0038,Pb ,0.0036,Fe ,99.14,Ti ,0.0036,Nb ,0
STS11, ,Sample No.:(38650 3.50X1100 SS400 C/N54460591 ),28-Mar-12,14:22:36,C ,0.1072,Si ,0.0082,Mn ,0.4049,P ,0.0081,S ,0.0075,Ni ,0.0097,Cr ,0.0148,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0557,V ,0.0032,Pb ,0.0034,Fe ,99.187,Ti ,0.0034,Nb ,0
STS11, ,Sample No.:(38653 3.50X1100 SS400 C/N54460581 ),28-Mar-12,14:26:32,C ,0.119,Si ,0.0053,Mn ,0.4458,P ,0.0111,S ,0.0122,Ni ,0.009,Cr ,0.0149,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0498,V ,0.0033,Pb ,0.0036,Fe ,99.136,Ti ,0.0034,Nb ,0
STS11, ,Sample No.:(38660 3.50X1100 SS400 C/N54460571 ),28-Mar-12,14:29:09,C ,0.1234,Si ,0.0064,Mn ,0.4773,P ,0.0068,S ,0.0085,Ni ,0.0087,Cr ,0.0142,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0584,V ,0.0026,Pb ,0.0035,Fe ,99.1,Ti ,0.0036R,Nb ,0
STS11, ,Sample No.:(38662 3.50X1100 SS400 C/N54460631 ),28-Mar-12,14:32:09,C ,0.1233,Si ,0.0067,Mn ,0.4354,P ,0.0119,S ,0.0121,Ni ,0.0092,Cr ,0.0133,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.05,V ,0.0027,Pb ,0.0034,Fe ,99.142,Ti ,0.0036R,Nb ,0
STS11, ,Sample No.:(38714 3.50X1100 SS400 C/N54330641 ),28-Mar-12,14:34:59,C ,0.1284,Si ,0.006,Mn ,0.4658,P ,0.0083,S ,0.0087,Ni ,0.0091,Cr ,0.0139,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0507,V ,0.0046,Pb ,0.0037,Fe ,99.11,Ti ,0.0039,Nb ,0
STS11, ,Sample No.:(38625 4.90X1080 SS400 C/N54360551 ),28-Mar-12,14:38:07,C ,0.1178,Si ,0.0052,Mn ,0.4464,P ,0.0077,S ,0.007,Ni ,0.0084,Cr ,0.0151,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0479,V ,0.0013,Pb ,0.0032,Fe ,99.149,Ti ,0.0037,Nb ,0
STS11, ,Sample No.:(38626 4.90X1080 SS400 C/N54360731 ),28-Mar-12,14:40:40,C ,0.1246,Si ,0.0085,Mn ,0.4526,P ,0.0081,S ,0.0076,Ni ,0.0085,Cr ,0.0139,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0452,V ,0.0014,Pb ,0.0032,Fe ,99.136,Ti ,0.0037,Nb ,0
STS11, ,Sample No.:(38632 4.90X1080 SS400 C/N54360881 ),28-Mar-12,14:42:40,C ,0.1079,Si ,0.0054,Mn ,0.4114,P ,0.0078,S ,0.0079,Ni ,0.0104,Cr ,0.0103,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0241,V ,0.0027,Pb ,0.0033,Fe ,99.218,Ti ,0.0039,Nb ,0
STS11, ,Sample No.:(38634 4.90X1080 SS400 C/N54360591 ),28-Mar-12,14:46:34,C ,0.1318,Si ,0.0045,Mn ,0.4545,P ,0.0115,S ,0.0064,Ni ,0.0086,Cr ,0.0116,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0504,V ,0.0025,Pb ,0.0033,Fe ,99.124,Ti ,0.0041,Nb ,0
STS11, ,Sample No.:(38647 4.90X1080 SS400 C/N54360891 ),28-Mar-12,14:50:42,C ,0.1379,Si ,0.0077,Mn ,0.4506,P ,0.0084,S ,0.0092,Ni ,0.0093,Cr ,0.0109,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.039,V ,0.0043,Pb ,0.0036,Fe ,99.129,Ti ,0.0035,Nb ,0
STS11, ,Sample No.:(38666 4.90X1080 SS400 C/N54360851 ),28-Mar-12,14:52:37,C ,0.1308,Si ,0.0062,Mn ,0.4585,P ,0.0093,S ,0.0077,Ni ,0.0095,Cr ,0.0146,Mo ,0.0006,Cu ,0,Co ,0.1863,Al ,0.0361,V ,0.0025,Pb ,0.0032,Fe ,99.131,Ti ,0.0035R,Nb ,0
ถ้าข้อมูลประมาณนี้ พอจะมีวิธีเขียน โค้ดมั้ยอะครับ ผมจะใช้วิธีการกดเลือก browse file csv เข้ามา โดยเราจะเอาแค่เฉพาะตัวเลข (ตัวอักษรพวก C,Cr,V,Si,Pb,Mn ไรพวกนี้ไม่เอาน่ะครับ)แล้ว บันทัดของข้อมูลแต่ละ record ก็มีจำนวนช่องว่างspaceberไม่เท่ากัน
ช่วยด้วยนะครับ งงมากๆเลย
ขอบคุณครับ
|
|
|
|
|
Date :
2012-06-14 14:54:01 |
By :
มือสมัครเล่น |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้างงๆก็ลอง copy ข้อมูลผมไปวาง ใน notepad ดูน่ะครับ ข้อมูลจะประมานนี้ครับ
|
|
|
|
|
Date :
2012-06-14 15:12:15 |
By :
มือสมัครเล่น |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่มีใครตอบเลย T_T
|
|
|
|
|
Date :
2012-06-22 08:54:12 |
By :
มือสมัครเล่น |
|
|
|
|
|
|
|
|
|
|
|
|
|
|