Как я импортирую файл пробельного разделенного текста в MySQL?

Посмотрите здесь . Вам нужно захватить координаты мыши и затем использовать cv.line

def click_and_crop(event, x, y, flags, param):
# grab references to the global variables
global refPt, cropping

# if the left mouse button was clicked, record the starting
# (x, y) coordinates and indicate that cropping is being
# performed
if event == cv2.EVENT_LBUTTONDOWN:
    refPt = [(x, y)]
    cropping = True

# check to see if the left mouse button was released
elif event == cv2.EVENT_LBUTTONUP:
    # record the ending (x, y) coordinates and indicate that
    # the cropping operation is finished
    # y = height x = width
    refPt.append((x, y))
    cropping = False
    # draw a rectangle around the region of interest
    #cv.line(input_frame, (0, int(height/2)), (int (width), int(height/2)), (0, 0xFF, 0), 5)
    cv2.line(image,(0, int(y)), (int(width), int(y)), (0, 255, 0), 2)
    cv2.imshow("image", image)

.

5
задан OMG Ponies 27 December 2009 в 03:27
поделиться

3 ответа

Если Вы находитесь на unix/linux затем, можно провести его через sed.

откройте терминал и тип:

sed 's/ \+/ /g' thefile > thefile.new

это заменяет все последовательности нескольких пробелов с одним пространством.

9
ответ дан 13 December 2019 в 19:39
поделиться

Можно также использовать ту же команду, отправленную Jauco для изменения разделителя на''; или \n. Это также помогло бы.

0
ответ дан 13 December 2019 в 19:39
поделиться

Нет ли никакой способ, которым можно сделать это практично? Простой Сценарий PHP смог бы загрузить файл в, разделенный пробелами, и сделать вставку в мгновение ока вообще:

<?php

$db = mysql_connect('host', 'user', 'password')
or die('Failed to connect');
mysql_select_db('database', $db);

$fileHandle= @fopen("import.file", "r");
if ($fileHandle) {
    while (!feof($fileHandle)) {
        $rawLine = fgets($fileHandle, 4096);

        $columns = preg_split("/\s+/", $rawLine);

        //Construct and run an INSERT statement here ...   

    }
    fclose($fileHandle);
}

?>

Редактирование Однако предложение Jakal намного более опрятно ;)

0
ответ дан 13 December 2019 в 19:39
поделиться
Другие вопросы по тегам:

Похожие вопросы: