עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ייבוא טבלת MYSQL מקובץ טקסט ללא הפרדה בין עמודות

Featured Replies

פורסם

אני מנסה להכניס קובץ נתונים של תוכנת DOS ישנה (קובץ ASCII נקי, עמודות ברוחב קבוע, ללא מפריד) לטבלת MYSQL

קובץ דוגמה (מפושט, אבל אותו מבנה) :

4444333666666
2222666555555
iiiiwwwcccccc
ttttxxxaaaaaa

mysql> create table t (col1 char(4) , col2 char(3) , col3 char (6) ) ;
Query OK, 0 rows affected (0.01 sec)

mysql> load data infile '/home/ash/1.txt' into table t fields terminated by '' enclosed by '' ;
Query OK, 4 rows affected, 8 warnings (0.00 sec)
Records: 4 Deleted: 0 Skipped: 0 Warnings: 8

mysql> select * from t ;
+------+------+------+
| col1 | col2 | col3 |
+------+------+------+
| 4444 | 6 | |
| 2222 | 5 | |
| iiii | c | |
| tttt | a | |
+------+------+------+
4 rows in set (0.00 sec)

איך מייבאים את הקובץ שהוא יצא נכון ?

ניסיתי לשנות char / varchar זה לא משנה כלום

פורסם

שים לב שהוא אומר שהיו 8 אזהרות. מומלץ לבדוק מה הן.

חוץ מזה:

http://dev.mysql.com/doc/refman/5.5/en/load-data.html

Note that fixed-size format does not work if you are using a multi-byte character set.

ומתוך ההערות:

First check to make sure your Fixed-Width is correct, then check your Table Format. I had to use latin1_general_ci to get the data to load. It would not accept my LOAD DATA INFILE with utf8_general_ci. So that should save some hairs on your head when you pull them out from the frustration.

אופציה נוספת היא פשוט לחלק את השורות בעצמך, באמצעות substr

To load a text file with fixed width columns, I used the form:

LOAD DATA LOCAL INFILE '<file name>' INTO TABLE <table>

(@var1)

SET Date=str_to_date(SUBSTR(@var1,3,10),'%m/%d/%Y'),

Time=SUBSTR(@var1,14,8),

WindVelocity=SUBSTR(@var1,26,5),

WindDirection=SUBSTR(@var1,33,3),

WindCompass=SUBSTR(@var1,38,3),

WindNorth=SUBSTR(@var1,43,6),

WindEast=SUBSTR(@var1,51,6),

WindSamples=SUBSTR(@var1,61,4);

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.