Index: trunk/MagicSoft/Mars/datacenter/macros/createdataset.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/createdataset.C	(revision 7165)
+++ trunk/MagicSoft/Mars/datacenter/macros/createdataset.C	(revision 7166)
@@ -82,4 +82,6 @@
     fouthtml << source << endl;
     fouthtml << "</td><td>" << endl;
+    if (wobble.Contains("Y"))
+        fouthtml << "wobble," << endl;
     if (startdate=="0000-00-00 00:00:00")
         fouthtml << "all" << endl;
@@ -121,43 +123,45 @@
     delete res;
 
-    if (off.Contains("none"))
-    {
-        cout << "no off chosen" << endl;
-        if (wobble.Contains("Y"))
+    if (wobble.Contains("N"))
+    {
+        if (off.Contains("none"))
         {
-            cout << "wobble mode -> finished" << endl;
-            return 1;
+            off  ="Off";
+            off +=source;
+            off.Remove(10,15);
         }
-        off  ="Off";
-        off +=source.Remove(7,12);
-    }
-
-    cout << "off: " << off << endl;
-    query  ="Select Sequences.fSequenceFirst from Sequences left join Source on ";
-    query +="Sequences.fSourceKEY=Source.fSourceKEY ";
-    if (cal)
-        query +=" left join SequenceProcessStatus on Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst ";
-    query +=Form("where fSourceName like '%s%%' and fRunStart between '%s' and '%s'",
-                 off.Data(), offstartdate.Data(), offstopdate.Data());
-    if (cal)
-        query +=" and not IsNull(fStar) ";
-    query +=" order by Sequences.fSequenceFirst ";
-
-    cout << "Q: " << query << endl;
-
-    res = serv.Query(query);
-    if (!res)
-    {
-        cout << "Error - no sequence found" << endl;
-        return 0;
-    }
-
-    fout << "SequencesOff: " << flush;
-    row=0;
-    while ((row = res->Next()))
-        fout << " " << (*row)[0] <<  " " << flush;
-    fout << endl << endl;
-
-    fout << "#SourceName: " << source << endl;
+
+        cout << "off: " << off << endl;
+        query  ="Select Sequences.fSequenceFirst from Sequences left join Source on ";
+        query +="Sequences.fSourceKEY=Source.fSourceKEY ";
+        if (cal)
+            query +=" left join SequenceProcessStatus on Sequences.fSequenceFirst=SequenceProcessStatus.fSequenceFirst ";
+        query +=Form("where fSourceName like '%s%%' and fRunStart between '%s' and '%s'",
+                     off.Data(), offstartdate.Data(), offstopdate.Data());
+        if (cal)
+            query +=" and not IsNull(fStar) ";
+        query +=" order by Sequences.fSequenceFirst ";
+
+        cout << "Q: " << query << endl;
+
+        res = serv.Query(query);
+        if (!res)
+        {
+            cout << "Error - no sequence found" << endl;
+            return 0;
+        }
+
+        fout << "SequencesOff: " << flush;
+        row=0;
+        while ((row = res->Next()))
+            fout << " " << (*row)[0] <<  " " << flush;
+        fout << endl << endl;
+
+        delete res;
+    }
+
+    if (wobble.Contains("N"))
+        fout << "#" << flush;
+    fout << "SourceName: " << source << endl;
     fout << "Catalog: /magic/datacenter/setup/magic_favorites.edb" << endl;
     if (wobble.Contains("N"))
@@ -165,7 +169,59 @@
     fout << "WobbleMode: On" << endl << endl;
 
-    delete res;
 
     return 1;
 }
 
+int createdataset(TString filename)
+{
+    ifstream fin(filename);
+    if (!fin)
+    {
+        cout << "Could not open file " << filename << endl;
+        return 0;
+    }
+    cout << "reading file " << filename << endl;
+
+    while (1)
+    {
+        TString strng;
+        strng.ReadToDelim(fin, ',');
+        if (!fin)
+            break;
+
+        if (strng.BeginsWith("#"))
+        {
+            cout << "comment line: " << strng << endl;
+            strng.ReadToDelim(fin, '\n');
+            continue;
+        }
+
+        Int_t dataset=atoi(strng.Data());
+        if (dataset==0)
+            continue;
+        cout << "creating dataset # " << dataset << endl;
+
+        TString source;
+        source.ReadToDelim(fin, ',');
+        TString wobble;
+        wobble.ReadToDelim(fin, ',');
+        strng.ReadToDelim(fin, ',');
+        Bool_t cal=kFALSE;
+        if (strng=="kTRUE")
+            cal=kTRUE;
+        TString startdate;
+        startdate.ReadToDelim(fin, ',');
+        TString stopdate;
+        stopdate.ReadToDelim(fin, ',');
+        TString off;
+        off.ReadToDelim(fin, ',');
+        TString offstartdate;
+        offstartdate.ReadToDelim(fin, ',');
+        TString offstopdate;
+        offstopdate.ReadToDelim(fin, '\n');
+
+        cout << createdataset(dataset, source, wobble, cal, startdate, stopdate, off, offstartdate, offstopdate) << endl;
+    }
+
+    return 1;
+}
Index: trunk/MagicSoft/Mars/datacenter/macros/insertdataset.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/insertdataset.C	(revision 7165)
+++ trunk/MagicSoft/Mars/datacenter/macros/insertdataset.C	(revision 7166)
@@ -121,8 +121,9 @@
     cout << endl;
 
-    Int_t sourcekey = QueryNameKEY(serv, dummy, "Source", source.Data());
+    Int_t sourcekey = QueryNameKEY(serv, dummy, "Source", source.Data(), kFALSE);
     if (sourcekey<0)
     {
-        cout << "Error - could not get sourcename from DB" << endl;
+        cout << "Error - could not get sourcename from DB -> " << flush;
+        cout << "maybe you have the wrong sourcename in your datasetfile" << endl;
         return 0;
     }
