The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Excel 2 Forum
Good day everybody,
I have an excel file with different rows and I want to create threads with content out of each row. Is there already something like a phyton script available for this? If not, can you give me some tipps and advice to start off how I could cope with something like this? Maybe there is even a coder who could code something like this in python for me? Greetings! |
#2
|
|||
|
|||
Is there a reason you want to use Python even though vBulletin 5 is created using PHP?
Using PHP you can read the Excel file and iterate through each row and then insert the thread. PHP Code:
|
#3
|
|||
|
|||
no, just because I am more into python at the moment.
Thanks already for the script. But how can I tell it to get the data from my excel exactly? Is there an example? --------------- Added [DATE]1572536085[/DATE] at [TIME]1572536085[/TIME] --------------- The excel file is structured as colum 1 = title colum = thread content there are x rows whereby each row should be a different thread. I understand the code you wrote there, but I dont get how I can link this to an excel file. Can you help me here? --------------- Added [DATE]1572543745[/DATE] at [TIME]1572543745[/TIME] --------------- It hasnt necessarly to be excel 2 vbulletin. Right now I just have all the data in an excel file. |
#4
|
|||
|
|||
I came a bit closer to the solution I guess, got some help from another guy regarding the importing problem from a csv file. But I can't get it working.
Anyone, any help here? Code:
$row = 1; if (($handle = fopen("yourdata.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($rowfields); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; ... $post_title = $rowfields[0]; $post_content = $rowfields[1]; ... // then you call the thread creator PostCreator(... } fclose($handle); } function PostCreator($title, $content... ) { ... // here you call the code to create the thread // it's not real code, just to help you figure it out $thread = $api->callApi('content_text', 'add', [ 'data' => [ 'rawtext' => $content, 'title' => $title, 'parentid' => 3, // ID of the forum section (or node as they call it in vBulletin 5) 'userid' => 1 // ID of the user to post the thread as ], 'options' => [ 'nl2br' => true ] ]); } |
#5
|
|||
|
|||
Something like:
PHP Code:
Pretty sure the script you gave is not valid though because it calls the $rowfields variable which does not exist. |
#6
|
|||
|
|||
thanks, I finally got it working. Many thanks 2 you!
|
#7
|
|||
|
|||
Hey Dave, the script works like a charm, thank you so much again for your help!
There just came up another question from my side. When I work with larg csv files (more than about 1000 lines) the script runs longer than the max. execution time allowed by my server. The most of the times I split the files into separate files, what works of course. But is there a "simple" way to update the script so that it also works with large files without running into problems with the max. execution time? Regards! |
#9
|
|||
|
|||
Seems to work, many thanks!
|
#10
|
|||
|
|||
Ok it is working, but not for me, since I cant change the set_time_limit at more than 90 seconds.
I could split my csv file into several files and then create several scripts which I have to run each after another. like: import_n.php imports import_n.csv n+1 Is there a way to automatically start import_2.php when import_1 is finished? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|