> I need to convert this to a table but the order of the data must stay the same. Try s:gsub('%["(%w+)"%]="(.-)",',print) Replace print with a suitable function. If the data file has more than one table, it'll take a little more work.