2013-03-15 2 views
0

바닐라 포럼 내보내기에서 SQL Server로 데이터를 가져 와서 일종의 스크립트를 작성하여 YAF.NET으로 가져올 수 있습니다. 필자는 통합 서비스 프로젝트와 SQL Server 가져 오기 마법사를 사용해 보았습니다. 포럼과 사용자는 결국 끝났지 만 주제 테이블에서 나에게 문제가 발생했습니다. 문제는 레코드 분리로, 플랫 파일 데이터 소스로 올바르게 분할 할 수 없습니다.바닐라 포럼을 SQL Server로 가져 오기

예 :

DiscussionID,CategoryID,InsertUserID,UpdateUserID,Name,Body,Format,CountComments,CountViews,Closed,Announce,Sink,DateInserted,DateUpdated,InsertIPAddress,UpdateIPAddress,DateLastComment,Score 
1,2,2,0,"Welcome","","Html",1,1,0,0,0,"2005-11-22 20:36:00","2005-11-22 20:36:00",\N,\N,"2005-11-22 20:36:00",\N 
13,5,5,0,"Custom Feilds","Hi Echilon\,\ 
\ 
I've been fiddling with iZeit Calendar a bit (though I haven't published anything\, as that would be inapropriate without your permission) and I have tried\, without success\, to add extra fields to both the input form and the calendar output.\ 
\ 
So far I've added the extra columns to the database\, attempted to edit the multiple queries in functions.php -> addevent() function with little success.\ 
\ 
I was wondering if you could help me out a bit in better understanding the flow of data from input fields to database query.\ 
\ 
Once I get the data into the database\, I shouldn't see any future problems of displaying it.\ 
\ 
I would also like to note that you've done a fantastic job with this software!\ 
\ 
-Ax","Html",4,1830,0,0,0,"2006-02-23 00:14:43","2006-02-24 18:57:53",\N,\N,"2006-02-24 18:57:53",\N 
3,4,2,0,"[Wallpaper] Aeon Genesis","<a target=\"_blank\" href=\"http://www.deviantart.com/deviation/24402244/\"></a><img src=\"http://mi6.nu/aeon_small.jpg\" border=\"0\" />\ 
<a target=\"_blank\" href=\"http://www.deviantart.com/deviation/24402244/\">Full Size - 1600x1200</a>\ 
\ 
I made this in 2004\, it's an edited photo of the view from my window at sunset.","Html",1,1052,0,0,0,"2005-11-23 09:46:29","2005-11-23 09:46:29",\N,\N,"2005-11-23 09:46:29",\N 
4,7,2,0,"Moodsig","This is a script which lets you pick a mood from a control panel\, then have it display that mood in a sig\, along with a random quote from a database. It's not quite finished yet\, but it should be released sometime this week. I just have to track down the guys who made the smileys for permission. It's a bit buggy at the minute\, but it should be working in a few days.\ 
\ 
At the minute\, you need PHP and a MySQL database\, but I might release a version which only needs php and a text file if there's demand for it.\ 
\ 
This is the control panel\, which controls the sig I'm using now.\ 
<a target=\"_blank\" href=\"http://mi6.nu/moodsig_0.8.jpg\"></a><img src=\"http://mi6.nu/moodsig_0.8_thumb.jpg\" border=\"0\" />","Html",1,1100,0,0,0,"2005-11-23 15:38:56","2005-11-23 15:38:56",\N,\N,"2005-11-23 15:38:56",\N 
5,4,2,0,"Dynasig 1.0","Dynasig lets you set your current mood with a web based control panel\, then display it aswell as a random quote in a signature which you can use on a forum.\ 
\ 
<b>Installation</b>\ 
You'll need a webserver with PHP and MySQL. In the future\, I might release a version that doesn't need MySQL\, but for now\, you have to have it. \ 
\ 
1) Set up a database on ... 

이 경우, 새로운 기록이 라인에서 시작 :

3,4,2,0,"[Wallpaper] Aeon Genesis","<a ta 
4,7,2,0,"Moodsig"," 
5,4,2,0,"Dynasig 1.0","Dynasig l 

가 어떻게 SQL 서버에이를 얻을 것 ?

+0

"내게 문제가 생기는"것은 오류, 예기치 않은 결과를 의미하는 것이 아닙니다. 그리고 샘플 데이터의 열과 행 구분 기호는 무엇입니까? 나는 종종 SSIS 또는 bcp.exe가 구분 기호 문제로 인해 큰 텍스트 필드가있는 CSV 파일을 구문 분석하지 못한다는 사실을 발견했습니다. 예를 들어 [이 연결 문제] (https://connect.microsoft.com/SQLServer/feedback/details/312164/flat-file-parser-cannot-import-files-with-embedded-text-qualifiers)를 참조하십시오. 좋은 CSV 지원 언어 (예 : Perl, Python)를 사용하는 외부 스크립트에서이 작업을 쉽게 수행 할 수 있습니다. – Pondlife

+0

죄송합니다, 올바른 분할 위치를 추가했습니다. – Echilon

답변

0

특정 구분 기호 (예 : 쉼표) 만 처리하는 경우 BULK INSERT 작업을 사용할 수 있습니다 (http://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server/ 참조).

BULK 
INSERT ForumTable 
FROM 'c:\ForumFlatFile.txt' 
WITH 
(
FIELDTERMINATOR = ',', 
ROWTERMINATOR = '\n' 
) 
GO 

특정 태그와 구문을 가져 오려면 (OP에서 말할 수는 없지만) 미안하지만 기능을 제안합니다. 예를 들어 포럼 게시물을 내보내는 방법에 따라 태그 사이에 특정 값을 구문 분석 할 수있는 함수를 빌드하십시오 (예 : A HREF 태그를 구문 분석하는 함수). 때때로 포럼 게시물은 특정 패턴으로 연결되고 끝날 수 있으며, 함수는 이러한 시작 및 끝 태그를 "인식"하여 중간 값을 가져올 수 있습니다.

관련 문제